UnifiedSearch: Introduce a DocumentBuilder interface (#96738)

This commit is contained in:
Ryan McKinley
2024-11-21 07:53:25 +02:00
committed by GitHub
parent 8d4db7ac85
commit 0cb6c3d7bf
24 changed files with 1428 additions and 8 deletions
+38
View File
@@ -19,3 +19,41 @@ func TestKeyMatching(t *testing.T) {
}))
})
}
func TestSearchIDKeys(t *testing.T) {
tests := []struct {
input string
expected *ResourceKey // nil error
}{
{input: "a"}, // error
{input: "default/group/resource/name",
expected: &ResourceKey{
Namespace: "default",
Group: "group",
Resource: "resource",
Name: "name",
}},
{input: "/group/resource/", // missing name
expected: &ResourceKey{
Namespace: "",
Group: "group",
Resource: "resource",
Name: "",
}},
{input: "**cluster**/group/resource/aaa", // cluster namespace
expected: &ResourceKey{
Namespace: "",
Group: "group",
Resource: "resource",
Name: "aaa",
}},
}
for _, test := range tests {
tmp := &ResourceKey{}
err := tmp.ReadSearchID(test.input)
if err == nil {
require.Equal(t, test.expected, tmp, test.input)
}
}
}