diff --git a/internal/index/digest_test.go b/internal/index/digest_test.go index 5f2d8467..001b067b 100644 --- a/internal/index/digest_test.go +++ b/internal/index/digest_test.go @@ -59,27 +59,31 @@ func TestWithIndex(t *testing.T) { } func TestNewDigester(t *testing.T) { + g := NewWithT(t) + t.Run("default", func(t *testing.T) { - g := NewWithT(t) - d := NewDigester() - g.Expect(d).ToNot(BeNil()) - g.Expect(d.index).ToNot(BeNil()) + g.Expect(d.index).To(BeEmpty()) g.Expect(d.digests).ToNot(BeNil()) }) t.Run("with index", func(t *testing.T) { - g := NewWithT(t) - - i := map[string]string{"foo": "bar"} - d := NewDigester(WithIndex(i)) - + initialIndex := map[string]string{"foo": "bar"} + d := NewDigester(WithIndex(initialIndex)) g.Expect(d).ToNot(BeNil()) - g.Expect(d.index).To(Equal(i)) + g.Expect(d.index).To(Equal(initialIndex)) g.Expect(d.digests).ToNot(BeNil()) }) + t.Run("handles multiple WithIndex options, applying last one", func(t *testing.T) { + firstIndex := map[string]string{"a": "b"} + secondIndex := map[string]string{"c": "d"} + d := NewDigester(WithIndex(firstIndex), WithIndex(secondIndex)) + g.Expect(d.index).To(Equal(secondIndex)) + }) +} + t.Run("handles multiple WithIndex options, applying last one", func(t *testing.T) { g := NewWithT(t) firstIndex := map[string]string{"a": "b"}