mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-24 20:24:09 +00:00
Merge pull request #84619 from seans3/move-printer-test
Move small test back to printers_test.go
This commit is contained in:
commit
58323cbf4e
@ -143,26 +143,6 @@ func TestJSONPrinter(t *testing.T) {
|
||||
testPrinter(t, genericprinters.NewTypeSetter(legacyscheme.Scheme).ToPrinter(&genericprinters.JSONPrinter{}), json.Unmarshal)
|
||||
}
|
||||
|
||||
// TODO(seans3): Move this test to cli-runtime/pkg/printers.
|
||||
func TestFormatResourceName(t *testing.T) {
|
||||
tests := []struct {
|
||||
kind schema.GroupKind
|
||||
name string
|
||||
want string
|
||||
}{
|
||||
{schema.GroupKind{}, "", ""},
|
||||
{schema.GroupKind{}, "name", "name"},
|
||||
{schema.GroupKind{Kind: "Kind"}, "", "kind/"}, // should not happen in practice
|
||||
{schema.GroupKind{Kind: "Kind"}, "name", "kind/name"},
|
||||
{schema.GroupKind{Group: "group", Kind: "Kind"}, "name", "kind.group/name"},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
if got := formatResourceName(tt.kind, tt.name, true); got != tt.want {
|
||||
t.Errorf("formatResourceName(%q, %q) = %q, want %q", tt.kind, tt.name, got, tt.want)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func PrintCustomType(obj *TestPrintType, options printers.GenerateOptions) ([]metav1beta1.TableRow, error) {
|
||||
return []metav1beta1.TableRow{{Cells: []interface{}{obj.Data}}}, nil
|
||||
}
|
||||
|
@ -24,6 +24,7 @@ import (
|
||||
"k8s.io/apimachinery/pkg/api/resource"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
metav1beta1 "k8s.io/apimachinery/pkg/apis/meta/v1beta1"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
"k8s.io/apimachinery/pkg/util/diff"
|
||||
"k8s.io/apimachinery/pkg/util/intstr"
|
||||
"k8s.io/kubernetes/pkg/apis/apps"
|
||||
@ -43,6 +44,25 @@ import (
|
||||
utilpointer "k8s.io/utils/pointer"
|
||||
)
|
||||
|
||||
func TestFormatResourceName(t *testing.T) {
|
||||
tests := []struct {
|
||||
kind schema.GroupKind
|
||||
name string
|
||||
want string
|
||||
}{
|
||||
{schema.GroupKind{}, "", ""},
|
||||
{schema.GroupKind{}, "name", "name"},
|
||||
{schema.GroupKind{Kind: "Kind"}, "", "kind/"}, // should not happen in practice
|
||||
{schema.GroupKind{Kind: "Kind"}, "name", "kind/name"},
|
||||
{schema.GroupKind{Group: "group", Kind: "Kind"}, "name", "kind.group/name"},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
if got := formatResourceName(tt.kind, tt.name, true); got != tt.want {
|
||||
t.Errorf("formatResourceName(%q, %q) = %q, want %q", tt.kind, tt.name, got, tt.want)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
type TestPrintHandler struct {
|
||||
numCalls int
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user