@@ -59,27 +59,31 @@ func TestWithIndex(t *testing.T) {
59
59
}
60
60
61
61
func TestNewDigester (t * testing.T ) {
62
- t .Run ("default" , func (t * testing.T ) {
63
- g := NewWithT (t )
62
+ g := NewWithT (t )
64
63
64
+ t .Run ("default" , func (t * testing.T ) {
65
65
d := NewDigester ()
66
-
67
66
g .Expect (d ).ToNot (BeNil ())
68
- g .Expect (d .index ).ToNot ( BeNil ())
67
+ g .Expect (d .index ).To ( BeEmpty ())
69
68
g .Expect (d .digests ).ToNot (BeNil ())
70
69
})
71
70
72
71
t .Run ("with index" , func (t * testing.T ) {
73
- g := NewWithT (t )
74
-
75
- i := map [string ]string {"foo" : "bar" }
76
- d := NewDigester (WithIndex (i ))
77
-
72
+ initialIndex := map [string ]string {"foo" : "bar" }
73
+ d := NewDigester (WithIndex (initialIndex ))
78
74
g .Expect (d ).ToNot (BeNil ())
79
- g .Expect (d .index ).To (Equal (i ))
75
+ g .Expect (d .index ).To (Equal (initialIndex ))
80
76
g .Expect (d .digests ).ToNot (BeNil ())
81
77
})
82
78
79
+ t .Run ("handles multiple WithIndex options, applying last one" , func (t * testing.T ) {
80
+ firstIndex := map [string ]string {"a" : "b" }
81
+ secondIndex := map [string ]string {"c" : "d" }
82
+ d := NewDigester (WithIndex (firstIndex ), WithIndex (secondIndex ))
83
+ g .Expect (d .index ).To (Equal (secondIndex ))
84
+ })
85
+ }
86
+
83
87
t .Run ("handles multiple WithIndex options, applying last one" , func (t * testing.T ) {
84
88
g := NewWithT (t )
85
89
firstIndex := map [string ]string {"a" : "b" }
0 commit comments