@@ -271,15 +271,15 @@ func TestKubectlCleanup(t *testing.T) {
271
271
}
272
272
273
273
func TestKubectlRedeploy (t * testing.T ) {
274
- tmpDir , cleanup := testutil .NewTempDir ( t )
275
- defer cleanup ()
276
- tmpDir . Write ("deployment-web.yaml" , deploymentWebYAML )
277
- tmpDir . Write ("deployment-app.yaml" , deploymentAppYAML )
274
+ testutil . Run ( t , "" , func ( t * testutil.T ) {
275
+ tmpDir := t . NewTempDir ().
276
+ Write ("deployment-web.yaml" , deploymentWebYAML ).
277
+ Write ("deployment-app.yaml" , deploymentAppYAML )
278
278
279
- reset := testutil .Override (t , & util .DefaultExecCommand , testutil . NewFakeCmd ( t ) .
280
- WithRunOut ("kubectl version --client -ojson" , kubectlVersion ).
281
- WithRunOut ("kubectl --context kubecontext --namespace testNamespace create --dry-run -oyaml -f " + tmpDir .Path ("deployment-app.yaml" )+ " -f " + tmpDir .Path ("deployment-web.yaml" ), deploymentAppYAML + "\n " + deploymentWebYAML ).
282
- WithRunInput ("kubectl --context kubecontext --namespace testNamespace apply -f -" , `apiVersion: v1
279
+ t .Override (& util .DefaultExecCommand , t .
280
+ FakeRunOut ("kubectl version --client -ojson" , kubectlVersion ).
281
+ WithRunOut ("kubectl --context kubecontext --namespace testNamespace create --dry-run -oyaml -f " + tmpDir .Path ("deployment-app.yaml" )+ " -f " + tmpDir .Path ("deployment-web.yaml" ), deploymentAppYAML + "\n " + deploymentWebYAML ).
282
+ WithRunInput ("kubectl --context kubecontext --namespace testNamespace apply -f -" , `apiVersion: v1
283
283
kind: Pod
284
284
metadata:
285
285
labels:
@@ -300,8 +300,8 @@ spec:
300
300
containers:
301
301
- image: leeroy-web:v1
302
302
name: leeroy-web` ).
303
- WithRunOut ("kubectl --context kubecontext --namespace testNamespace create --dry-run -oyaml -f " + tmpDir .Path ("deployment-app.yaml" )+ " -f " + tmpDir .Path ("deployment-web.yaml" ), deploymentAppYAML + "\n " + deploymentWebYAML ).
304
- WithRunInput ("kubectl --context kubecontext --namespace testNamespace apply -f -" , `apiVersion: v1
303
+ WithRunOut ("kubectl --context kubecontext --namespace testNamespace create --dry-run -oyaml -f " + tmpDir .Path ("deployment-app.yaml" )+ " -f " + tmpDir .Path ("deployment-web.yaml" ), deploymentAppYAML + "\n " + deploymentWebYAML ).
304
+ WithRunInput ("kubectl --context kubecontext --namespace testNamespace apply -f -" , `apiVersion: v1
305
305
kind: Pod
306
306
metadata:
307
307
labels:
@@ -311,47 +311,47 @@ spec:
311
311
containers:
312
312
- image: leeroy-app:v2
313
313
name: leeroy-app` ).
314
- WithRunOut ("kubectl --context kubecontext --namespace testNamespace create --dry-run -oyaml -f " + tmpDir .Path ("deployment-app.yaml" )+ " -f " + tmpDir .Path ("deployment-web.yaml" ), deploymentAppYAML + "\n " + deploymentWebYAML ),
315
- )
316
- defer reset ()
314
+ WithRunOut ("kubectl --context kubecontext --namespace testNamespace create --dry-run -oyaml -f " + tmpDir .Path ("deployment-app.yaml" )+ " -f " + tmpDir .Path ("deployment-web.yaml" ), deploymentAppYAML + "\n " + deploymentWebYAML ),
315
+ )
317
316
318
- cfg := & latest.KubectlDeploy {
319
- Manifests : []string {tmpDir .Path ("deployment-app.yaml" ), "deployment-web.yaml" },
320
- }
321
- deployer := NewKubectlDeployer (& runcontext.RunContext {
322
- WorkingDir : tmpDir .Root (),
323
- Cfg : & latest.Pipeline {
324
- Deploy : latest.DeployConfig {
325
- DeployType : latest.DeployType {
326
- KubectlDeploy : cfg ,
317
+ cfg := & latest.KubectlDeploy {
318
+ Manifests : []string {tmpDir .Path ("deployment-app.yaml" ), "deployment-web.yaml" },
319
+ }
320
+ deployer := NewKubectlDeployer (& runcontext.RunContext {
321
+ WorkingDir : tmpDir .Root (),
322
+ Cfg : & latest.Pipeline {
323
+ Deploy : latest.DeployConfig {
324
+ DeployType : latest.DeployType {
325
+ KubectlDeploy : cfg ,
326
+ },
327
327
},
328
328
},
329
- },
330
- KubeContext : testKubeContext ,
331
- Opts : & config.SkaffoldOptions {
332
- Namespace : testNamespace ,
333
- },
334
- })
335
- labellers := []Labeller {deployer }
329
+ KubeContext : testKubeContext ,
330
+ Opts : & config.SkaffoldOptions {
331
+ Namespace : testNamespace ,
332
+ },
333
+ })
334
+ labellers := []Labeller {deployer }
336
335
337
- // Deploy one manifest
338
- err := deployer .Deploy (context .Background (), ioutil .Discard , []build.Artifact {
339
- {ImageName : "leeroy-web" , Tag : "leeroy-web:v1" },
340
- {ImageName : "leeroy-app" , Tag : "leeroy-app:v1" },
341
- }, labellers )
342
- testutil . CheckError ( t , false , err )
336
+ // Deploy one manifest
337
+ err := deployer .Deploy (context .Background (), ioutil .Discard , []build.Artifact {
338
+ {ImageName : "leeroy-web" , Tag : "leeroy-web:v1" },
339
+ {ImageName : "leeroy-app" , Tag : "leeroy-app:v1" },
340
+ }, labellers )
341
+ t . CheckNoError ( err )
343
342
344
- // Deploy one manifest since only one image is updated
345
- err = deployer .Deploy (context .Background (), ioutil .Discard , []build.Artifact {
346
- {ImageName : "leeroy-web" , Tag : "leeroy-web:v1" },
347
- {ImageName : "leeroy-app" , Tag : "leeroy-app:v2" },
348
- }, labellers )
349
- testutil . CheckError ( t , false , err )
343
+ // Deploy one manifest since only one image is updated
344
+ err = deployer .Deploy (context .Background (), ioutil .Discard , []build.Artifact {
345
+ {ImageName : "leeroy-web" , Tag : "leeroy-web:v1" },
346
+ {ImageName : "leeroy-app" , Tag : "leeroy-app:v2" },
347
+ }, labellers )
348
+ t . CheckNoError ( err )
350
349
351
- // Deploy zero manifest since no image is updated
352
- err = deployer .Deploy (context .Background (), ioutil .Discard , []build.Artifact {
353
- {ImageName : "leeroy-web" , Tag : "leeroy-web:v1" },
354
- {ImageName : "leeroy-app" , Tag : "leeroy-app:v2" },
355
- }, labellers )
356
- testutil .CheckError (t , false , err )
350
+ // Deploy zero manifest since no image is updated
351
+ err = deployer .Deploy (context .Background (), ioutil .Discard , []build.Artifact {
352
+ {ImageName : "leeroy-web" , Tag : "leeroy-web:v1" },
353
+ {ImageName : "leeroy-app" , Tag : "leeroy-app:v2" },
354
+ }, labellers )
355
+ t .CheckNoError (err )
356
+ })
357
357
}
0 commit comments