Skip to content

Commit

Permalink
Merge pull request #96761 from ingvagabund/kubectl-explicit-test-name…
Browse files Browse the repository at this point in the history
…space

kubectl/pkg/cmd tests: set explicit namespace
  • Loading branch information
k8s-ci-robot committed Dec 9, 2020
2 parents d543031 + d4e8954 commit d8fbc52
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 19 deletions.
32 changes: 16 additions & 16 deletions staging/src/k8s.io/kubectl/pkg/cmd/debug/debug_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1178,7 +1178,7 @@ func TestGenerateNodeDebugPod(t *testing.T) {
}

func TestCompleteAndValidate(t *testing.T) {
tf := cmdtesting.NewTestFactory()
tf := cmdtesting.NewTestFactory().WithNamespace("test")
ioStreams, _, _, _ := genericclioptions.NewTestIOStreams()
cmpFilter := cmp.FilterPath(func(p cmp.Path) bool {
switch p.String() {
Expand Down Expand Up @@ -1225,7 +1225,7 @@ func TestCompleteAndValidate(t *testing.T) {
wantOpts: &DebugOptions{
Args: []string{},
Image: "busybox",
Namespace: "default",
Namespace: "test",
PullPolicy: corev1.PullPolicy("Always"),
ShareProcesses: true,
TargetNames: []string{"mypod"},
Expand All @@ -1237,7 +1237,7 @@ func TestCompleteAndValidate(t *testing.T) {
wantOpts: &DebugOptions{
Args: []string{},
Image: "busybox",
Namespace: "default",
Namespace: "test",
ShareProcesses: true,
TargetNames: []string{"mypod1", "mypod2"},
},
Expand All @@ -1248,7 +1248,7 @@ func TestCompleteAndValidate(t *testing.T) {
wantOpts: &DebugOptions{
Args: []string{"echo", "1", "2"},
Image: "busybox",
Namespace: "default",
Namespace: "test",
ShareProcesses: true,
TargetNames: []string{"mypod1", "mypod2"},
},
Expand All @@ -1261,7 +1261,7 @@ func TestCompleteAndValidate(t *testing.T) {
Attach: false,
Image: "busybox",
Interactive: true,
Namespace: "default",
Namespace: "test",
ShareProcesses: true,
TargetNames: []string{"mypod"},
TTY: true,
Expand All @@ -1274,7 +1274,7 @@ func TestCompleteAndValidate(t *testing.T) {
Args: []string{},
Env: []v1.EnvVar{{Name: "FOO", Value: "BAR"}},
Image: "busybox",
Namespace: "default",
Namespace: "test",
ShareProcesses: true,
TargetNames: []string{"mypod"},
},
Expand All @@ -1287,7 +1287,7 @@ func TestCompleteAndValidate(t *testing.T) {
Attach: true,
Image: "busybox",
Interactive: true,
Namespace: "default",
Namespace: "test",
ShareProcesses: true,
TargetNames: []string{"mypod"},
TTY: true,
Expand All @@ -1300,7 +1300,7 @@ func TestCompleteAndValidate(t *testing.T) {
Args: []string{},
Container: "debugger",
Image: "myproj/debug-tools",
Namespace: "default",
Namespace: "test",
PullPolicy: corev1.PullPolicy("Always"),
ShareProcesses: true,
TargetNames: []string{"mypod"},
Expand Down Expand Up @@ -1340,7 +1340,7 @@ func TestCompleteAndValidate(t *testing.T) {
CopyTo: "my-debugger",
Image: "busybox",
Interactive: true,
Namespace: "default",
Namespace: "test",
ShareProcesses: true,
TargetNames: []string{"mypod"},
TTY: true,
Expand All @@ -1354,7 +1354,7 @@ func TestCompleteAndValidate(t *testing.T) {
Container: "my-container",
CopyTo: "my-debugger",
Image: "busybox",
Namespace: "default",
Namespace: "test",
ShareProcesses: true,
TargetNames: []string{"mypod"},
},
Expand All @@ -1367,7 +1367,7 @@ func TestCompleteAndValidate(t *testing.T) {
Attach: true,
CopyTo: "my-debugger",
Image: "busybox",
Namespace: "default",
Namespace: "test",
ShareProcesses: true,
TargetNames: []string{"mypod"},
},
Expand All @@ -1380,7 +1380,7 @@ func TestCompleteAndValidate(t *testing.T) {
Container: "my-container",
CopyTo: "my-debugger",
Image: "busybox",
Namespace: "default",
Namespace: "test",
ShareProcesses: true,
TargetNames: []string{"mypod"},
},
Expand All @@ -1391,7 +1391,7 @@ func TestCompleteAndValidate(t *testing.T) {
wantOpts: &DebugOptions{
Args: []string{},
CopyTo: "my-debugger",
Namespace: "default",
Namespace: "test",
SetImages: map[string]string{
"*": "busybox",
"app": "app-debugger",
Expand All @@ -1409,7 +1409,7 @@ func TestCompleteAndValidate(t *testing.T) {
CopyTo: "my-debugger",
Image: "debian",
Interactive: true,
Namespace: "default",
Namespace: "test",
SetImages: map[string]string{
"app": "app:debug",
"sidecar": "sidecar:debug",
Expand All @@ -1428,7 +1428,7 @@ func TestCompleteAndValidate(t *testing.T) {
Container: "mycontainer",
CopyTo: "my-debugger",
Interactive: true,
Namespace: "default",
Namespace: "test",
ShareProcesses: true,
TargetNames: []string{"mypod"},
TTY: true,
Expand Down Expand Up @@ -1467,7 +1467,7 @@ func TestCompleteAndValidate(t *testing.T) {
Attach: true,
Image: "busybox",
Interactive: true,
Namespace: "default",
Namespace: "test",
ShareProcesses: true,
TargetNames: []string{"node/mynode"},
TTY: true,
Expand Down
6 changes: 3 additions & 3 deletions staging/src/k8s.io/kubectl/pkg/cmd/run/run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,7 @@ func TestExpose(t *testing.T) {
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {

tf := cmdtesting.NewTestFactory()
tf := cmdtesting.NewTestFactory().WithNamespace("test")
defer tf.Cleanup()

codec := scheme.Codecs.LegacyCodec(scheme.Scheme.PrioritizedVersionsAllGroups()...)
Expand All @@ -570,11 +570,11 @@ func TestExpose(t *testing.T) {
Client: fake.CreateHTTPClient(func(req *http.Request) (*http.Response, error) {
t.Logf("path: %v, method: %v", req.URL.Path, req.Method)
switch p, m := req.URL.Path, req.Method; {
case m == "POST" && p == "/namespaces/default/pods":
case m == "POST" && p == "/namespaces/test/pods":
pod := &corev1.Pod{}
body := cmdtesting.ObjBody(codec, pod)
return &http.Response{StatusCode: http.StatusOK, Header: cmdtesting.DefaultHeader(), Body: body}, nil
case m == "POST" && p == "/namespaces/default/services":
case m == "POST" && p == "/namespaces/test/services":
data, err := ioutil.ReadAll(req.Body)
if err != nil {
t.Fatalf("unexpected error: %v", err)
Expand Down

0 comments on commit d8fbc52

Please sign in to comment.