From d67a982985b7990a2525dacf76515b0946fe245c Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Fri, 5 Jul 2024 10:35:59 +0200 Subject: [PATCH] Test UUID#Value() --- types/uuid_test.go | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 types/uuid_test.go diff --git a/types/uuid_test.go b/types/uuid_test.go new file mode 100644 index 00000000..70f9a621 --- /dev/null +++ b/types/uuid_test.go @@ -0,0 +1,29 @@ +package types + +import ( + "github.com/google/uuid" + "github.com/stretchr/testify/require" + "testing" +) + +func TestUUID_Value(t *testing.T) { + nonzero := uuid.New() + + subtests := []struct { + name string + input uuid.UUID + output []byte + }{ + {"zero", uuid.UUID{}, make([]byte, 16)}, + {"nonzero", nonzero, nonzero[:]}, + } + + for _, st := range subtests { + t.Run(st.name, func(t *testing.T) { + actual, err := UUID{st.input}.Value() + + require.NoError(t, err) + require.Equal(t, st.output, actual) + }) + } +}