From 0331f47a6ad8ef16f5c2c7cec9bad58ce4ecedc6 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Wed, 4 Sep 2024 18:05:13 +0200 Subject: [PATCH] Test icingadb.EntitiesById#Keys() --- pkg/icingadb/entitiesbyid_test.go | 37 +++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 pkg/icingadb/entitiesbyid_test.go diff --git a/pkg/icingadb/entitiesbyid_test.go b/pkg/icingadb/entitiesbyid_test.go new file mode 100644 index 000000000..ca2d0856a --- /dev/null +++ b/pkg/icingadb/entitiesbyid_test.go @@ -0,0 +1,37 @@ +package icingadb + +import ( + "github.com/icinga/icingadb/pkg/icingadb/v1" + "github.com/stretchr/testify/require" + "testing" +) + +func TestEntitiesById_Keys(t *testing.T) { + subtests := []struct { + name string + input EntitiesById + output []string + }{ + {name: "nil"}, + { + name: "empty", + input: EntitiesById{}, + }, + { + name: "one", + input: EntitiesById{"one": nil}, + output: []string{"one"}, + }, + { + name: "two", + input: EntitiesById{"one": nil, "two": &v1.EntityWithoutChecksum{}}, + output: []string{"one", "two"}, + }, + } + + for _, st := range subtests { + t.Run(st.name, func(t *testing.T) { + require.ElementsMatch(t, st.output, st.input.Keys()) + }) + } +}