Skip to content

Commit 58323cb

Browse files
authored
Merge pull request kubernetes#84619 from seans3/move-printer-test
Move small test back to printers_test.go
2 parents 07023f2 + ce85e86 commit 58323cb

File tree

2 files changed

+20
-20
lines changed

2 files changed

+20
-20
lines changed

pkg/printers/internalversion/additional_printers_test.go

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -143,26 +143,6 @@ func TestJSONPrinter(t *testing.T) {
143143
testPrinter(t, genericprinters.NewTypeSetter(legacyscheme.Scheme).ToPrinter(&genericprinters.JSONPrinter{}), json.Unmarshal)
144144
}
145145

146-
// TODO(seans3): Move this test to cli-runtime/pkg/printers.
147-
func TestFormatResourceName(t *testing.T) {
148-
tests := []struct {
149-
kind schema.GroupKind
150-
name string
151-
want string
152-
}{
153-
{schema.GroupKind{}, "", ""},
154-
{schema.GroupKind{}, "name", "name"},
155-
{schema.GroupKind{Kind: "Kind"}, "", "kind/"}, // should not happen in practice
156-
{schema.GroupKind{Kind: "Kind"}, "name", "kind/name"},
157-
{schema.GroupKind{Group: "group", Kind: "Kind"}, "name", "kind.group/name"},
158-
}
159-
for _, tt := range tests {
160-
if got := formatResourceName(tt.kind, tt.name, true); got != tt.want {
161-
t.Errorf("formatResourceName(%q, %q) = %q, want %q", tt.kind, tt.name, got, tt.want)
162-
}
163-
}
164-
}
165-
166146
func PrintCustomType(obj *TestPrintType, options printers.GenerateOptions) ([]metav1beta1.TableRow, error) {
167147
return []metav1beta1.TableRow{{Cells: []interface{}{obj.Data}}}, nil
168148
}

pkg/printers/internalversion/printers_test.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import (
2424
"k8s.io/apimachinery/pkg/api/resource"
2525
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2626
metav1beta1 "k8s.io/apimachinery/pkg/apis/meta/v1beta1"
27+
"k8s.io/apimachinery/pkg/runtime/schema"
2728
"k8s.io/apimachinery/pkg/util/diff"
2829
"k8s.io/apimachinery/pkg/util/intstr"
2930
"k8s.io/kubernetes/pkg/apis/apps"
@@ -43,6 +44,25 @@ import (
4344
utilpointer "k8s.io/utils/pointer"
4445
)
4546

47+
func TestFormatResourceName(t *testing.T) {
48+
tests := []struct {
49+
kind schema.GroupKind
50+
name string
51+
want string
52+
}{
53+
{schema.GroupKind{}, "", ""},
54+
{schema.GroupKind{}, "name", "name"},
55+
{schema.GroupKind{Kind: "Kind"}, "", "kind/"}, // should not happen in practice
56+
{schema.GroupKind{Kind: "Kind"}, "name", "kind/name"},
57+
{schema.GroupKind{Group: "group", Kind: "Kind"}, "name", "kind.group/name"},
58+
}
59+
for _, tt := range tests {
60+
if got := formatResourceName(tt.kind, tt.name, true); got != tt.want {
61+
t.Errorf("formatResourceName(%q, %q) = %q, want %q", tt.kind, tt.name, got, tt.want)
62+
}
63+
}
64+
}
65+
4666
type TestPrintHandler struct {
4767
numCalls int
4868
}

0 commit comments

Comments
 (0)