-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Signed-off-by: Yusan Kurban <[email protected]>
- Loading branch information
Showing
3 changed files
with
102 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package options | ||
|
||
import ( | ||
"reflect" | ||
"testing" | ||
|
||
"k8s.io/apimachinery/pkg/runtime/schema" | ||
) | ||
|
||
func TestOptions_PreCacheResourcesToGVKList(t *testing.T) { | ||
type fields struct { | ||
PreCacheResources string | ||
} | ||
tests := []struct { | ||
name string | ||
fields fields | ||
want []schema.GroupVersionKind | ||
}{ | ||
{ | ||
name: "empty", | ||
fields: fields{}, | ||
want: make([]schema.GroupVersionKind, 0), | ||
}, | ||
{ | ||
name: "pod", | ||
fields: fields{ | ||
PreCacheResources: "Pod/v1", | ||
}, | ||
want: []schema.GroupVersionKind{ | ||
{ | ||
Version: "v1", | ||
Kind: "Pod", | ||
}, | ||
}, | ||
}, | ||
{ | ||
name: "Deployment", | ||
fields: fields{ | ||
PreCacheResources: "Pod/apps/v1", | ||
}, | ||
want: []schema.GroupVersionKind{ | ||
{ | ||
Group: "apps", | ||
Version: "v1", | ||
Kind: "Pod", | ||
}, | ||
}, | ||
}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
o := &Options{ | ||
PreCacheResources: tt.fields.PreCacheResources, | ||
} | ||
if got := o.PreCacheResourcesToGVKList(); !reflect.DeepEqual(got, tt.want) { | ||
t.Errorf("PreCacheResourcesToGVKList() = %v, want %v", got, tt.want) | ||
} | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters