This repository has been archived by the owner on Dec 3, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
options_test.go
75 lines (65 loc) · 1.49 KB
/
options_test.go
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
package golden
import (
"io/fs"
"testing"
)
func TestGolden_WithFilePerms(t *testing.T) {
t.Run("change file permission to 0666", func(t *testing.T) {
want := fs.FileMode(0666)
g := New(t,
WithFilePerms(want),
)
if g.filePerms != want {
t.Errorf("mismatch got=%v, want=%v", g.filePerms, want)
}
})
}
func TestGolden_WithDirPerms(t *testing.T) {
t.Run("change directory permission to 0666", func(t *testing.T) {
want := fs.FileMode(0666)
g := New(t,
WithDirPerms(want),
)
if g.dirPerms != want {
t.Errorf("mismatch got=%v, want=%v", g.dirPerms, want)
}
})
}
func TestGolden_WithDiffEngine(t *testing.T) {
t.Run("change diff engine to simple one", func(t *testing.T) {
want := Simple
g := New(t,
WithDiffEngine(want),
)
if g.diffEngine != want {
t.Errorf("mismatch got=%v, want=%v", g.diffEngine, want)
}
})
}
func TestGolden_WithDiffFn(t *testing.T) {
t.Run("change diff function", func(t *testing.T) {
want := "change-diff-func"
f := func(actual, expected string) string {
return want
}
g := New(t,
WithDiffFn(f),
)
got := g.diffFn("actual", "expected")
if got != want {
t.Errorf("mismatch got=%s, want=%s", got, want)
}
})
}
func TestGolden_WithIgnoreTemplateErrors(t *testing.T) {
t.Run("change diff function", func(t *testing.T) {
want := true
g := New(t,
WithIgnoreTemplateErrors(want),
)
got := g.ignoreTemplateErrors
if got != want {
t.Errorf("mismatch got=%v, want=%v", g.ignoreTemplateErrors, want)
}
})
}