@@ -46,6 +46,7 @@ func testPack(t *testing.T, context spec.G, it spec.S) {
46
46
Expect (os .RemoveAll (tmpDir )).To (Succeed ())
47
47
Expect (os .RemoveAll (buildpackDir )).To (Succeed ())
48
48
})
49
+
49
50
context ("when packaging a language family buildpack" , func () {
50
51
51
52
it .Before (func () {
@@ -331,17 +332,68 @@ func testPack(t *testing.T, context spec.G, it spec.S) {
331
332
Expect (hdr .Mode ).To (Equal (int64 (0644 )))
332
333
})
333
334
})
335
+ })
336
+
337
+ context ("failure cases" , func () {
338
+ context ("when the all the required flags are not set" , func () {
339
+ it ("prints an error message" , func () {
340
+ command := exec .Command (path , "pack" )
341
+ session , err := gexec .Start (command , buffer , buffer )
342
+ Expect (err ).NotTo (HaveOccurred ())
343
+ Eventually (session ).Should (gexec .Exit (1 ), func () string { return buffer .String () })
344
+
345
+ Expect (session .Err .Contents ()).To (ContainSubstring ("Error: required flag(s) \" buildpack\" , \" output\" , \" version\" not set" ))
346
+ })
347
+ })
348
+
349
+ context ("when the required buildpack flag is not set" , func () {
350
+ it ("prints an error message" , func () {
351
+ command := exec .Command (
352
+ path , "pack" ,
353
+ "--output" , filepath .Join (tmpDir , "output.tgz" ),
354
+ "--version" , "some-version" ,
355
+ "--offline" ,
356
+ "--stack" , "io.buildpacks.stacks.bionic" ,
357
+ )
358
+ session , err := gexec .Start (command , buffer , buffer )
359
+ Expect (err ).NotTo (HaveOccurred ())
360
+ Eventually (session ).Should (gexec .Exit (1 ), func () string { return buffer .String () })
361
+
362
+ Expect (session .Err .Contents ()).To (ContainSubstring ("Error: required flag(s) \" buildpack\" not set" ))
363
+ })
364
+ })
334
365
335
- context ("failure cases" , func () {
336
- context ("when the --buildpack flag is empty" , func () {
337
- it ("prints an error message" , func () {
338
- command := exec .Command (path , "pack" )
339
- session , err := gexec .Start (command , buffer , buffer )
340
- Expect (err ).NotTo (HaveOccurred ())
341
- Eventually (session ).Should (gexec .Exit (1 ), func () string { return buffer .String () })
366
+ context ("when the required output flag is not set" , func () {
367
+ it ("prints an error message" , func () {
368
+ command := exec .Command (
369
+ path , "pack" ,
370
+ "--buildpack" , filepath .Join (buildpackDir , "buildpack.toml" ),
371
+ "--version" , "some-version" ,
372
+ "--offline" ,
373
+ "--stack" , "io.buildpacks.stacks.bionic" ,
374
+ )
375
+ session , err := gexec .Start (command , buffer , buffer )
376
+ Expect (err ).NotTo (HaveOccurred ())
377
+ Eventually (session ).Should (gexec .Exit (1 ), func () string { return buffer .String () })
378
+
379
+ Expect (session .Err .Contents ()).To (ContainSubstring ("Error: required flag(s) \" output\" not set" ))
380
+ })
381
+ })
382
+
383
+ context ("when the required version flag is not set" , func () {
384
+ it ("prints an error message" , func () {
385
+ command := exec .Command (
386
+ path , "pack" ,
387
+ "--buildpack" , filepath .Join (buildpackDir , "buildpack.toml" ),
388
+ "--output" , filepath .Join (tmpDir , "output.tgz" ),
389
+ "--offline" ,
390
+ "--stack" , "io.buildpacks.stacks.bionic" ,
391
+ )
392
+ session , err := gexec .Start (command , buffer , buffer )
393
+ Expect (err ).NotTo (HaveOccurred ())
394
+ Eventually (session ).Should (gexec .Exit (1 ), func () string { return buffer .String () })
342
395
343
- Expect (session .Err .Contents ()).To (ContainSubstring ("Error: required flag(s) \" buildpack\" , \" version\" not set" ))
344
- })
396
+ Expect (session .Err .Contents ()).To (ContainSubstring ("Error: required flag(s) \" version\" not set" ))
345
397
})
346
398
})
347
399
})
0 commit comments