kubectl/pkg/cmd tests: set explicit namespace
Otherwise, the namespace gets set to what's a current namespace in provided kubeconfig. Which can be different from default. Kubernetes-commit: d4e89547f065ac5eee67ab4646fb3cee874dc1a9
This commit is contained in:
parent
655e2db3c7
commit
6fea4885d8
|
@ -1178,7 +1178,7 @@ func TestGenerateNodeDebugPod(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestCompleteAndValidate(t *testing.T) {
|
func TestCompleteAndValidate(t *testing.T) {
|
||||||
tf := cmdtesting.NewTestFactory()
|
tf := cmdtesting.NewTestFactory().WithNamespace("test")
|
||||||
ioStreams, _, _, _ := genericclioptions.NewTestIOStreams()
|
ioStreams, _, _, _ := genericclioptions.NewTestIOStreams()
|
||||||
cmpFilter := cmp.FilterPath(func(p cmp.Path) bool {
|
cmpFilter := cmp.FilterPath(func(p cmp.Path) bool {
|
||||||
switch p.String() {
|
switch p.String() {
|
||||||
|
@ -1225,7 +1225,7 @@ func TestCompleteAndValidate(t *testing.T) {
|
||||||
wantOpts: &DebugOptions{
|
wantOpts: &DebugOptions{
|
||||||
Args: []string{},
|
Args: []string{},
|
||||||
Image: "busybox",
|
Image: "busybox",
|
||||||
Namespace: "default",
|
Namespace: "test",
|
||||||
PullPolicy: corev1.PullPolicy("Always"),
|
PullPolicy: corev1.PullPolicy("Always"),
|
||||||
ShareProcesses: true,
|
ShareProcesses: true,
|
||||||
TargetNames: []string{"mypod"},
|
TargetNames: []string{"mypod"},
|
||||||
|
@ -1237,7 +1237,7 @@ func TestCompleteAndValidate(t *testing.T) {
|
||||||
wantOpts: &DebugOptions{
|
wantOpts: &DebugOptions{
|
||||||
Args: []string{},
|
Args: []string{},
|
||||||
Image: "busybox",
|
Image: "busybox",
|
||||||
Namespace: "default",
|
Namespace: "test",
|
||||||
ShareProcesses: true,
|
ShareProcesses: true,
|
||||||
TargetNames: []string{"mypod1", "mypod2"},
|
TargetNames: []string{"mypod1", "mypod2"},
|
||||||
},
|
},
|
||||||
|
@ -1248,7 +1248,7 @@ func TestCompleteAndValidate(t *testing.T) {
|
||||||
wantOpts: &DebugOptions{
|
wantOpts: &DebugOptions{
|
||||||
Args: []string{"echo", "1", "2"},
|
Args: []string{"echo", "1", "2"},
|
||||||
Image: "busybox",
|
Image: "busybox",
|
||||||
Namespace: "default",
|
Namespace: "test",
|
||||||
ShareProcesses: true,
|
ShareProcesses: true,
|
||||||
TargetNames: []string{"mypod1", "mypod2"},
|
TargetNames: []string{"mypod1", "mypod2"},
|
||||||
},
|
},
|
||||||
|
@ -1261,7 +1261,7 @@ func TestCompleteAndValidate(t *testing.T) {
|
||||||
Attach: false,
|
Attach: false,
|
||||||
Image: "busybox",
|
Image: "busybox",
|
||||||
Interactive: true,
|
Interactive: true,
|
||||||
Namespace: "default",
|
Namespace: "test",
|
||||||
ShareProcesses: true,
|
ShareProcesses: true,
|
||||||
TargetNames: []string{"mypod"},
|
TargetNames: []string{"mypod"},
|
||||||
TTY: true,
|
TTY: true,
|
||||||
|
@ -1274,7 +1274,7 @@ func TestCompleteAndValidate(t *testing.T) {
|
||||||
Args: []string{},
|
Args: []string{},
|
||||||
Env: []v1.EnvVar{{Name: "FOO", Value: "BAR"}},
|
Env: []v1.EnvVar{{Name: "FOO", Value: "BAR"}},
|
||||||
Image: "busybox",
|
Image: "busybox",
|
||||||
Namespace: "default",
|
Namespace: "test",
|
||||||
ShareProcesses: true,
|
ShareProcesses: true,
|
||||||
TargetNames: []string{"mypod"},
|
TargetNames: []string{"mypod"},
|
||||||
},
|
},
|
||||||
|
@ -1287,7 +1287,7 @@ func TestCompleteAndValidate(t *testing.T) {
|
||||||
Attach: true,
|
Attach: true,
|
||||||
Image: "busybox",
|
Image: "busybox",
|
||||||
Interactive: true,
|
Interactive: true,
|
||||||
Namespace: "default",
|
Namespace: "test",
|
||||||
ShareProcesses: true,
|
ShareProcesses: true,
|
||||||
TargetNames: []string{"mypod"},
|
TargetNames: []string{"mypod"},
|
||||||
TTY: true,
|
TTY: true,
|
||||||
|
@ -1300,7 +1300,7 @@ func TestCompleteAndValidate(t *testing.T) {
|
||||||
Args: []string{},
|
Args: []string{},
|
||||||
Container: "debugger",
|
Container: "debugger",
|
||||||
Image: "myproj/debug-tools",
|
Image: "myproj/debug-tools",
|
||||||
Namespace: "default",
|
Namespace: "test",
|
||||||
PullPolicy: corev1.PullPolicy("Always"),
|
PullPolicy: corev1.PullPolicy("Always"),
|
||||||
ShareProcesses: true,
|
ShareProcesses: true,
|
||||||
TargetNames: []string{"mypod"},
|
TargetNames: []string{"mypod"},
|
||||||
|
@ -1340,7 +1340,7 @@ func TestCompleteAndValidate(t *testing.T) {
|
||||||
CopyTo: "my-debugger",
|
CopyTo: "my-debugger",
|
||||||
Image: "busybox",
|
Image: "busybox",
|
||||||
Interactive: true,
|
Interactive: true,
|
||||||
Namespace: "default",
|
Namespace: "test",
|
||||||
ShareProcesses: true,
|
ShareProcesses: true,
|
||||||
TargetNames: []string{"mypod"},
|
TargetNames: []string{"mypod"},
|
||||||
TTY: true,
|
TTY: true,
|
||||||
|
@ -1354,7 +1354,7 @@ func TestCompleteAndValidate(t *testing.T) {
|
||||||
Container: "my-container",
|
Container: "my-container",
|
||||||
CopyTo: "my-debugger",
|
CopyTo: "my-debugger",
|
||||||
Image: "busybox",
|
Image: "busybox",
|
||||||
Namespace: "default",
|
Namespace: "test",
|
||||||
ShareProcesses: true,
|
ShareProcesses: true,
|
||||||
TargetNames: []string{"mypod"},
|
TargetNames: []string{"mypod"},
|
||||||
},
|
},
|
||||||
|
@ -1367,7 +1367,7 @@ func TestCompleteAndValidate(t *testing.T) {
|
||||||
Attach: true,
|
Attach: true,
|
||||||
CopyTo: "my-debugger",
|
CopyTo: "my-debugger",
|
||||||
Image: "busybox",
|
Image: "busybox",
|
||||||
Namespace: "default",
|
Namespace: "test",
|
||||||
ShareProcesses: true,
|
ShareProcesses: true,
|
||||||
TargetNames: []string{"mypod"},
|
TargetNames: []string{"mypod"},
|
||||||
},
|
},
|
||||||
|
@ -1380,7 +1380,7 @@ func TestCompleteAndValidate(t *testing.T) {
|
||||||
Container: "my-container",
|
Container: "my-container",
|
||||||
CopyTo: "my-debugger",
|
CopyTo: "my-debugger",
|
||||||
Image: "busybox",
|
Image: "busybox",
|
||||||
Namespace: "default",
|
Namespace: "test",
|
||||||
ShareProcesses: true,
|
ShareProcesses: true,
|
||||||
TargetNames: []string{"mypod"},
|
TargetNames: []string{"mypod"},
|
||||||
},
|
},
|
||||||
|
@ -1391,7 +1391,7 @@ func TestCompleteAndValidate(t *testing.T) {
|
||||||
wantOpts: &DebugOptions{
|
wantOpts: &DebugOptions{
|
||||||
Args: []string{},
|
Args: []string{},
|
||||||
CopyTo: "my-debugger",
|
CopyTo: "my-debugger",
|
||||||
Namespace: "default",
|
Namespace: "test",
|
||||||
SetImages: map[string]string{
|
SetImages: map[string]string{
|
||||||
"*": "busybox",
|
"*": "busybox",
|
||||||
"app": "app-debugger",
|
"app": "app-debugger",
|
||||||
|
@ -1409,7 +1409,7 @@ func TestCompleteAndValidate(t *testing.T) {
|
||||||
CopyTo: "my-debugger",
|
CopyTo: "my-debugger",
|
||||||
Image: "debian",
|
Image: "debian",
|
||||||
Interactive: true,
|
Interactive: true,
|
||||||
Namespace: "default",
|
Namespace: "test",
|
||||||
SetImages: map[string]string{
|
SetImages: map[string]string{
|
||||||
"app": "app:debug",
|
"app": "app:debug",
|
||||||
"sidecar": "sidecar:debug",
|
"sidecar": "sidecar:debug",
|
||||||
|
@ -1428,7 +1428,7 @@ func TestCompleteAndValidate(t *testing.T) {
|
||||||
Container: "mycontainer",
|
Container: "mycontainer",
|
||||||
CopyTo: "my-debugger",
|
CopyTo: "my-debugger",
|
||||||
Interactive: true,
|
Interactive: true,
|
||||||
Namespace: "default",
|
Namespace: "test",
|
||||||
ShareProcesses: true,
|
ShareProcesses: true,
|
||||||
TargetNames: []string{"mypod"},
|
TargetNames: []string{"mypod"},
|
||||||
TTY: true,
|
TTY: true,
|
||||||
|
@ -1467,7 +1467,7 @@ func TestCompleteAndValidate(t *testing.T) {
|
||||||
Attach: true,
|
Attach: true,
|
||||||
Image: "busybox",
|
Image: "busybox",
|
||||||
Interactive: true,
|
Interactive: true,
|
||||||
Namespace: "default",
|
Namespace: "test",
|
||||||
ShareProcesses: true,
|
ShareProcesses: true,
|
||||||
TargetNames: []string{"node/mynode"},
|
TargetNames: []string{"node/mynode"},
|
||||||
TTY: true,
|
TTY: true,
|
||||||
|
|
|
@ -560,7 +560,7 @@ func TestExpose(t *testing.T) {
|
||||||
for _, test := range tests {
|
for _, test := range tests {
|
||||||
t.Run(test.name, func(t *testing.T) {
|
t.Run(test.name, func(t *testing.T) {
|
||||||
|
|
||||||
tf := cmdtesting.NewTestFactory()
|
tf := cmdtesting.NewTestFactory().WithNamespace("test")
|
||||||
defer tf.Cleanup()
|
defer tf.Cleanup()
|
||||||
|
|
||||||
codec := scheme.Codecs.LegacyCodec(scheme.Scheme.PrioritizedVersionsAllGroups()...)
|
codec := scheme.Codecs.LegacyCodec(scheme.Scheme.PrioritizedVersionsAllGroups()...)
|
||||||
|
@ -570,11 +570,11 @@ func TestExpose(t *testing.T) {
|
||||||
Client: fake.CreateHTTPClient(func(req *http.Request) (*http.Response, error) {
|
Client: fake.CreateHTTPClient(func(req *http.Request) (*http.Response, error) {
|
||||||
t.Logf("path: %v, method: %v", req.URL.Path, req.Method)
|
t.Logf("path: %v, method: %v", req.URL.Path, req.Method)
|
||||||
switch p, m := 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{}
|
pod := &corev1.Pod{}
|
||||||
body := cmdtesting.ObjBody(codec, pod)
|
body := cmdtesting.ObjBody(codec, pod)
|
||||||
return &http.Response{StatusCode: http.StatusOK, Header: cmdtesting.DefaultHeader(), Body: body}, nil
|
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)
|
data, err := ioutil.ReadAll(req.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unexpected error: %v", err)
|
t.Fatalf("unexpected error: %v", err)
|
||||||
|
|
Loading…
Reference in New Issue