-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdiff_test.go
More file actions
81 lines (69 loc) · 2.02 KB
/
Copy pathdiff_test.go
File metadata and controls
81 lines (69 loc) · 2.02 KB
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
76
77
78
79
80
81
package main
import "testing"
func TestBuildSettingsDiffOnlyIncludesOnlyDifferent(t *testing.T) {
defaultSettings := map[string]interface{}{
"B": uint32(2),
"A": "same",
"C": "default-only",
}
defaultTypes := map[string]RegistryType{
"A": RegString,
"B": RegDWord,
"C": RegString,
}
sessionSettings := map[string]interface{}{
"A": "same",
"B": uint32(3),
}
got := buildSettings(defaultSettings, defaultTypes, sessionSettings, false)
if len(got) != 1 {
t.Fatalf("len(buildSettings(..., false)) = %d, want 1", len(got))
}
if got[0].Name != "B" {
t.Fatalf("got[0].Name = %q, want %q", got[0].Name, "B")
}
if got[0].Type != RegDWord {
t.Fatalf("got[0].Type = %v, want %v", got[0].Type, RegDWord)
}
if !got[0].IsDifferent {
t.Fatalf("got[0].IsDifferent = false, want true")
}
}
func TestBuildSettingsShowAllIncludesUnchangedAndMissingAndSorted(t *testing.T) {
defaultSettings := map[string]interface{}{
"B": uint32(2),
"A": "same",
"C": "default-only",
}
defaultTypes := map[string]RegistryType{
"A": RegString,
"B": RegDWord,
"C": RegString,
}
sessionSettings := map[string]interface{}{
"A": "same",
"B": uint32(3),
}
got := buildSettings(defaultSettings, defaultTypes, sessionSettings, true)
if len(got) != 3 {
t.Fatalf("len(buildSettings(..., true)) = %d, want 3", len(got))
}
if got[0].Name != "A" || got[1].Name != "B" || got[2].Name != "C" {
t.Fatalf("names = [%s, %s, %s], want [A, B, C]", got[0].Name, got[1].Name, got[2].Name)
}
if got[0].IsDifferent {
t.Fatalf("A IsDifferent = true, want false")
}
if !got[1].IsDifferent {
t.Fatalf("B IsDifferent = false, want true")
}
if got[2].IsDifferent {
t.Fatalf("C IsDifferent = true, want false")
}
if got[2].CurrentValue != got[2].DefaultValue {
t.Fatalf("C CurrentValue = %#v, want default %#v", got[2].CurrentValue, got[2].DefaultValue)
}
if got[0].Type != RegString || got[1].Type != RegDWord || got[2].Type != RegString {
t.Fatalf("unexpected types: got [%v %v %v]", got[0].Type, got[1].Type, got[2].Type)
}
}