@@ -61,12 +61,13 @@ spec:
61
61
62
62
func TestKubectlDeploy (t * testing.T ) {
63
63
tests := []struct {
64
- description string
65
- cfg * latest.KubectlDeploy
66
- builds []build.Artifact
67
- commands util.Command
68
- shouldErr bool
69
- forceDeploy bool
64
+ description string
65
+ cfg * latest.KubectlDeploy
66
+ builds []build.Artifact
67
+ commands util.Command
68
+ shouldErr bool
69
+ forceDeploy bool
70
+ skipSkaffoldNamespaceOption bool
70
71
}{
71
72
{
72
73
description : "no manifest" ,
@@ -133,6 +134,22 @@ func TestKubectlDeploy(t *testing.T) {
133
134
Tag : "leeroy-web:123" ,
134
135
}},
135
136
},
137
+ {
138
+ description : "deploy success (default namespace)" ,
139
+ cfg : & latest.KubectlDeploy {
140
+ Manifests : []string {"deployment.yaml" },
141
+ DefaultNamespace : & testNamespace2 ,
142
+ },
143
+ commands : testutil .
144
+ CmdRunOut ("kubectl version --client -ojson" , kubectlVersion118 ).
145
+ AndRunOut ("kubectl --context kubecontext --namespace testNamespace2 create --dry-run=client -oyaml -f deployment.yaml" , deploymentWebYAML ).
146
+ AndRun ("kubectl --context kubecontext --namespace testNamespace2 apply -f -" ),
147
+ builds : []build.Artifact {{
148
+ ImageName : "leeroy-web" ,
149
+ Tag : "leeroy-web:123" ,
150
+ }},
151
+ skipSkaffoldNamespaceOption : true ,
152
+ },
136
153
{
137
154
description : "http manifest" ,
138
155
cfg : & latest.KubectlDeploy {
@@ -191,6 +208,11 @@ func TestKubectlDeploy(t *testing.T) {
191
208
Touch ("empty.ignored" ).
192
209
Chdir ()
193
210
211
+ skaffoldNamespaceOption := ""
212
+ if ! test .skipSkaffoldNamespaceOption {
213
+ skaffoldNamespaceOption = testNamespace
214
+ }
215
+
194
216
k := NewKubectlDeployer (& runcontext.RunContext {
195
217
WorkingDir : "." ,
196
218
Cfg : latest.Pipeline {
@@ -202,7 +224,7 @@ func TestKubectlDeploy(t *testing.T) {
202
224
},
203
225
KubeContext : testKubeContext ,
204
226
Opts : config.SkaffoldOptions {
205
- Namespace : testNamespace ,
227
+ Namespace : skaffoldNamespaceOption ,
206
228
Force : test .forceDeploy ,
207
229
},
208
230
})
0 commit comments