@@ -81,7 +81,6 @@ func TestRunGenerateCommand(t *testing.T) {
8181 t .Parallel ()
8282 r := & generateRunner {
8383 api : test .api ,
84- apiSource : t .TempDir (),
8584 repo : test .repo ,
8685 sourceRepo : newTestGitRepo (t ),
8786 ghClient : test .ghClient ,
@@ -326,29 +325,28 @@ func TestRunConfigureCommand(t *testing.T) {
326325 } {
327326 t .Run (test .name , func (t * testing.T ) {
328327 t .Parallel ()
329- sourcePath := t .TempDir ()
330328 r := & generateRunner {
331329 api : test .api ,
332- apiSource : sourcePath ,
333330 repo : test .repo ,
331+ sourceRepo : newTestGitRepo (t ),
334332 state : test .state ,
335333 containerClient : test .container ,
336334 }
337335
338336 // Create a service config
339- if err := os .MkdirAll (filepath .Join (r .apiSource , test .api ), 0755 ); err != nil {
337+ if err := os .MkdirAll (filepath .Join (r .sourceRepo . GetDir () , test .api ), 0755 ); err != nil {
340338 t .Fatal (err )
341339 }
342340
343341 data := []byte ("type: google.api.Service" )
344- if err := os .WriteFile (filepath .Join (r .apiSource , test .api , "example_service_v2.yaml" ), data , 0755 ); err != nil {
342+ if err := os .WriteFile (filepath .Join (r .sourceRepo . GetDir () , test .api , "example_service_v2.yaml" ), data , 0755 ); err != nil {
345343 t .Fatal (err )
346344 }
347345
348346 if test .name == "configures library with non-existent api source" {
349347 // This test verifies the scenario of no service config is found
350348 // in api path.
351- if err := os .RemoveAll (filepath .Join (r .apiSource )); err != nil {
349+ if err := os .RemoveAll (filepath .Join (r .sourceRepo . GetDir () )); err != nil {
352350 t .Fatal (err )
353351 }
354352 }
@@ -961,13 +959,11 @@ func TestGenerateScenarios(t *testing.T) {
961959 },
962960 } {
963961 t .Run (test .name , func (t * testing.T ) {
964- apiSource := t .TempDir ()
965962 repo := newTestGitRepoWithState (t , test .state , true )
966963
967964 r := & generateRunner {
968965 api : test .api ,
969966 library : test .library ,
970- apiSource : apiSource ,
971967 build : test .build ,
972968 repo : repo ,
973969 sourceRepo : newTestGitRepo (t ),
@@ -979,11 +975,11 @@ func TestGenerateScenarios(t *testing.T) {
979975 }
980976
981977 // Create a service config in api path.
982- if err := os .MkdirAll (filepath .Join (r .apiSource , test .api ), 0755 ); err != nil {
978+ if err := os .MkdirAll (filepath .Join (r .sourceRepo . GetDir () , test .api ), 0755 ); err != nil {
983979 t .Fatal (err )
984980 }
985981 data := []byte ("type: google.api.Service" )
986- if err := os .WriteFile (filepath .Join (r .apiSource , test .api , "example_service_v2.yaml" ), data , 0755 ); err != nil {
982+ if err := os .WriteFile (filepath .Join (r .sourceRepo . GetDir () , test .api , "example_service_v2.yaml" ), data , 0755 ); err != nil {
987983 t .Fatal (err )
988984 }
989985
0 commit comments