INNER CODE UNIT · Go
TestGetNamespaceRoleAnnotationNilAnnotations
jtblin/kube2iam · namespace_test.go:74
func TestGetNamespaceRoleAnnotationNilAnnotations(t *testing.T) {
ns := &v1.Namespace{}
// No annotations set at all
result := GetNamespaceRoleAnnotation(ns, "namespaceKey")
if result != nil {
t.Errorf("expected nil for nil annotations, got %v", result)
}
}
// ---- NamespaceIndexFunc -----------------------------------------------------
func TestNamespaceIndexFunc(t *testing.T) {
ns := &v1.Namespace{ObjectMeta: metav1.ObjectMeta{Name: "my-namespace"}}
keys, err := NamespaceIndexFunc(ns)
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
if len(keys) != 1 || keys[0] != "my-namespace" {