...
1 package yamlfmt
2
3 import (
4 "fmt"
5 "testing"
6 )
7
8 func TestIgnorer(t *testing.T) {
9 dir := "testdata"
10 ignorer, err := NewIgnorer(dir)
11 if err != nil {
12 t.Fatal(err)
13 }
14
15 pathTests := map[string]bool{
16 "configmap.yaml": true,
17 "allyaml/configmap4.yaml": true,
18 "allyaml/configmap.yaml": true,
19 "nest1/nest2/deployment.yaml": true,
20 "nest1/nest2/another.yaml": false,
21 "bunk.yaml": false,
22 "direct_path/tester.yaml": true,
23
24
25 }
26
27 for path, expected := range pathTests {
28 ignoreCheck := ignorer.IgnorePath(path)
29 fmt.Printf("%s test: expected: %t got %t\n", path, expected, ignoreCheck)
30 if expected != ignoreCheck {
31 t.Errorf("%s failed to ignore", path)
32 }
33 }
34 }
35
View as plain text