Skip to content

Commit

Permalink
Fix typo
Browse files Browse the repository at this point in the history
  • Loading branch information
isindir committed May 6, 2024
1 parent 7246d82 commit 1ac441f
Showing 1 changed file with 80 additions and 0 deletions.
80 changes: 80 additions & 0 deletions pkg/kor/namespaces_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package kor

import (
"testing"

"k8s.io/apimachinery/pkg/runtime/schema"
)

func TestIgnoreResourceType(t *testing.T) {
Expand Down Expand Up @@ -53,3 +55,81 @@ func TestIgnoreResourceType(t *testing.T) {
})
}
}

func TestGetGVR(t *testing.T) {
type args struct {
name string
splitGV []string
}
tests := []struct {
name string
args args
want *schema.GroupVersionResource
expectErr bool
}{
{
name: "number of parts 0 - expect error",
args: args{
name: "deployments",
splitGV: []string{},
},
want: nil,
expectErr: true,
},
{
name: "number of parts 1",
args: args{
name: "secrets",
splitGV: []string{
"v1",
},
},
want: &schema.GroupVersionResource{
Group: "",
Version: "v1",
Resource: "secrets",
},
expectErr: false,
},
{
name: "number of parts 2",
args: args{
name: "deployments",
splitGV: []string{
"apps",
"v1",
},
},
want: &schema.GroupVersionResource{
Group: "apps",
Version: "v1",
Resource: "deployments",
},
expectErr: false,
},
{
name: "number of parts 4 - expect error",
args: args{
name: "deployments",
splitGV: []string{
"apps",
"v1",
"test-deploy01",
},
},
want: nil,
expectErr: true,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, err := getGVR(tt.args.name, tt.args.splitGV)
if (err != nil) != tt.expectErr {
t.Errorf("getGVR() = expected error: %t, got: '%v'", tt.expectErr, err)
}
if got != nil && *got != *tt.want {
t.Errorf("getGVR() = %+v, want %+v", got, tt.want)
}
})
}
}

0 comments on commit 1ac441f

Please sign in to comment.