From 47d0cbc0d9c0001b696ee64fcf8aaed2c86f1da4 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Thu, 5 Sep 2024 16:28:00 +0200 Subject: [PATCH] Test types.NotificationType#Value() --- pkg/icingadb/types/notification_type_test.go | 24 ++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/pkg/icingadb/types/notification_type_test.go b/pkg/icingadb/types/notification_type_test.go index a3da0672..18aaf863 100644 --- a/pkg/icingadb/types/notification_type_test.go +++ b/pkg/icingadb/types/notification_type_test.go @@ -33,3 +33,27 @@ func TestNotificationType_UnmarshalText(t *testing.T) { }) } } + +func TestNotificationType_Value(t *testing.T) { + subtests := []struct { + name string + input NotificationType + output string + error bool + }{ + {name: "zero", input: 0, error: true}, + {name: "bad", input: 3, error: true}, + {name: "good", input: 32, output: "problem"}, + } + + for _, st := range subtests { + t.Run(st.name, func(t *testing.T) { + if v, err := st.input.Value(); st.error { + require.Error(t, err) + } else { + require.NoError(t, err) + require.Equal(t, st.output, v) + } + }) + } +}