mirror of
https://github.com/fleetdm/fleet
synced 2026-04-21 21:47:20 +00:00
47 lines
732 B
Go
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)
|
|
}
|
|
}
|