@@ -71,6 +71,7 @@ func TestRunGenerateCommand(t *testing.T) {
71
71
APISource : t .TempDir (),
72
72
},
73
73
repo : test .repo ,
74
+ sourceRepo : newTestGitRepo (t ),
74
75
ghClient : test .ghClient ,
75
76
state : test .state ,
76
77
containerClient : test .container ,
@@ -387,7 +388,6 @@ func TestNewGenerateRunner(t *testing.T) {
387
388
{
388
389
name : "missing image" ,
389
390
cfg : & config.Config {
390
-
391
391
API : "some/api" ,
392
392
APISource : t .TempDir (),
393
393
Repo : "https://github.com/googleapis/librarian.git" ,
@@ -406,6 +406,16 @@ func TestNewGenerateRunner(t *testing.T) {
406
406
GitHubToken : "gh-token" ,
407
407
},
408
408
},
409
+ {
410
+ name : "empty API source" ,
411
+ cfg : & config.Config {
412
+ API : "some/api" ,
413
+ APISource : "" , // This will trigger the clone of googleapis
414
+ Repo : newTestGitRepo (t ).GetDir (),
415
+ WorkRoot : t .TempDir (),
416
+ Image : "gcr.io/test/test-image" ,
417
+ },
418
+ },
409
419
{
410
420
name : "clone googleapis fails" ,
411
421
cfg : & config.Config {
@@ -456,7 +466,7 @@ func TestNewGenerateRunner(t *testing.T) {
456
466
457
467
if test .cfg .APISource == "" && test .cfg .WorkRoot != "" {
458
468
if test .name == "clone googleapis fails" {
459
- // The function will try to clone googleapis into the workroot .
469
+ // The function will try to clone googleapis into the current work directory .
460
470
// To make it fail, create a non-empty, non-git directory.
461
471
googleapisDir := filepath .Join (test .cfg .WorkRoot , "googleapis" )
462
472
if err := os .MkdirAll (googleapisDir , 0755 ); err != nil {
@@ -466,7 +476,7 @@ func TestNewGenerateRunner(t *testing.T) {
466
476
t .Fatalf ("os.WriteFile() = %v" , err )
467
477
}
468
478
} else {
469
- // The function will try to clone googleapis into the workroot .
479
+ // The function will try to clone googleapis into the current work directory .
470
480
// To prevent a real clone, we can pre-create a fake googleapis repo.
471
481
googleapisDir := filepath .Join (test .cfg .WorkRoot , "googleapis" )
472
482
if err := os .MkdirAll (googleapisDir , 0755 ); err != nil {
0 commit comments