fleet/orbit/pkg/dataflatten/row_test.go
2023-11-01 20:11:35 -06:00

47 lines
732 B
Go

// based on github.com/kolide/launcher/pkg/osquery/tables
package dataflatten
import (
"testing"
"github.com/stretchr/testify/require"
)
func TestRowParentFunctions(t *testing.T) {
t.Parallel()
var tests = []struct {
in Row
parent string
key string
}{
{
in: Row{},
},
{
in: Row{Path: []string{}},
},
{
in: Row{Path: []string{"a"}},
parent: "",
key: "a",
},
{
in: Row{Path: []string{"a", "b"}},
parent: "a",
key: "b",
},
{
in: Row{Path: []string{"a", "b", "c"}},
parent: "a/b",
key: "c",
},
}
for _, tt := range tests {
parent, key := tt.in.ParentKey("/")
require.Equal(t, tt.parent, parent)
require.Equal(t, tt.key, key)
}
}