~nvkv/amitm

ref: bffe321917e01d7fb2f6516c6a4bafb506c339d5 amitm/internal/config/v1/config_test.go -rw-r--r-- 656 bytes
bffe3219Semyon Novikov Make amitm minimally useful 3 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package config

import (
	"fmt"
	"testing"
)

func TestReadConfig(t *testing.T) {
	fixture := []byte(`
[[rules]]
name = "Golang"
globs = ["*.go"]
action = "put"

[[rules.pipeline]]
exec = ["go", "fmt", "$file"]

[[rules.pipeline]]
exec = ["echo", "'Done formatting $file'"]

[[rules]]
name = "Terraform"
globs = ["*.tf", "*.tfvars"]
action = "put"

[[rules.pipeline]]
exec = ["terraform13", "fmt", "$file"]`)

	cfg, err := NewConfig(fixture)
	for k, rs := range cfg.actionmap {
		fmt.Printf("%s =>\n", k)
		for _, r := range rs {
			fmt.Printf("\t%s\n", r.Name)
		}
	}
	if err != nil || cfg == nil {
		t.Errorf("Can't read %s file: %s", fixture, err)
	}
}