@@ -292,8 +292,8 @@ func TestDetectNoRelease(t *testing.T) {
292
292
t .Fatal ("exit status is non-zero:" , status )
293
293
}
294
294
out := stdout .String ()
295
- if out != "" {
296
- t .Fatalf ("stdout is not empty : %q" , out )
295
+ if out != "No new release was found \n " {
296
+ t .Fatalf ("stdout is unexpected : %q" , out )
297
297
}
298
298
})
299
299
}
@@ -373,11 +373,10 @@ func TestWriteError(t *testing.T) {
373
373
}
374
374
375
375
func TestCouldNotFetch (t * testing.T ) {
376
- stdout := testErrorWriter {}
377
376
stderr := & bytes.Buffer {}
378
377
f := filepath .Join ("testdata" , "registry" , "repo_not_found.json" )
379
378
380
- status := newGen (stdout , stderr , io .Discard ).run ([]string {"test" , "-r" , f })
379
+ status := newGen (io . Discard , stderr , io .Discard ).run ([]string {"test" , "-r" , f })
381
380
if status == 0 {
382
381
t .Fatal ("exit status is unexpectedly zero" )
383
382
}
@@ -400,10 +399,9 @@ func TestInvalidCommandArgs(t *testing.T) {
400
399
401
400
for _ , tc := range testCases {
402
401
t .Run (strings .Join (tc .args , " " ), func (t * testing.T ) {
403
- stdout := testErrorWriter {}
404
402
stderr := & bytes.Buffer {}
405
403
406
- status := newGen (stdout , stderr , io .Discard ).run (tc .args )
404
+ status := newGen (io . Discard , stderr , io .Discard ).run (tc .args )
407
405
if status == 0 {
408
406
t .Fatal ("exit status is unexpectedly zero" )
409
407
}
@@ -430,6 +428,38 @@ func TestDetectErrorBadRequest(t *testing.T) {
430
428
}
431
429
}
432
430
431
+ func TestReadActionRegistryError (t * testing.T ) {
432
+ tests := []struct {
433
+ file string
434
+ want string
435
+ }{
436
+ {
437
+ file : "broken.json" ,
438
+ want : "could not parse the local action registry file as JSON:" ,
439
+ },
440
+ {
441
+ file : "oops-this-file-doesnt-exist.json" ,
442
+ want : "could not read the file for actions registry:" ,
443
+ },
444
+ }
445
+
446
+ for _ , tc := range tests {
447
+ t .Run (tc .file , func (t * testing.T ) {
448
+ stdout := io .Discard
449
+ stderr := & bytes.Buffer {}
450
+ f := filepath .Join ("testdata" , "registry" , tc .file )
451
+ status := newGen (stdout , stderr , io .Discard ).run ([]string {"test" , "-d" , "-r" , f })
452
+ if status != 1 {
453
+ t .Fatal ("exit status is not 1:" , status )
454
+ }
455
+ out := stderr .String ()
456
+ if ! strings .Contains (out , tc .want ) {
457
+ t .Fatalf ("wanted %q in stderr: %q" , tc .want , out )
458
+ }
459
+ })
460
+ }
461
+ }
462
+
433
463
func TestActionBuildRawURL (t * testing.T ) {
434
464
a := & registry {Slug : "foo/bar" }
435
465
have := a .rawURL ("v1" )
0 commit comments