Skip to content

Commit

Permalink
Test icingadb.EntitiesById#Keys()
Browse files Browse the repository at this point in the history
  • Loading branch information
Al2Klimov committed Sep 5, 2024
1 parent 277a61d commit 0331f47
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions pkg/icingadb/entitiesbyid_test.go
Original file line number Diff line number Diff line change
@@ -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())
})
}
}

0 comments on commit 0331f47

Please sign in to comment.