@@ -130,6 +130,40 @@ func TestRunBuildCommand(t *testing.T) {
130130 build : true ,
131131 container : & mockContainerClient {},
132132 },
133+ {
134+ name : "build with no response" ,
135+ build : true ,
136+ libraryID : "some-library" ,
137+ repo : newTestGitRepo (t ),
138+ state : & config.LibrarianState {
139+ Libraries : []* config.LibraryState {
140+ {
141+ ID : "some-library" ,
142+ },
143+ },
144+ },
145+ container : & mockContainerClient {
146+ noBuildResponse : true ,
147+ },
148+ wantErr : true ,
149+ },
150+ {
151+ name : "build with error response in response" ,
152+ build : true ,
153+ libraryID : "some-library" ,
154+ repo : newTestGitRepo (t ),
155+ state : & config.LibrarianState {
156+ Libraries : []* config.LibraryState {
157+ {
158+ ID : "some-library" ,
159+ },
160+ },
161+ },
162+ container : & mockContainerClient {
163+ wantErrorMsg : true ,
164+ },
165+ wantErr : true ,
166+ },
133167 } {
134168 t .Run (test .name , func (t * testing.T ) {
135169 t .Parallel ()
@@ -141,6 +175,7 @@ func TestRunBuildCommand(t *testing.T) {
141175 state : test .state ,
142176 containerClient : test .container ,
143177 }
178+
144179 err := r .runBuildCommand (context .Background (), test .libraryID )
145180 if test .wantErr {
146181 if err == nil {
@@ -170,7 +205,7 @@ func TestRunConfigureCommand(t *testing.T) {
170205 wantErr bool
171206 }{
172207 {
173- name : "configures library" ,
208+ name : "configures library successfully " ,
174209 api : "some/api" ,
175210 repo : newTestGitRepo (t ),
176211 state : & config.LibrarianState {
@@ -200,6 +235,24 @@ func TestRunConfigureCommand(t *testing.T) {
200235 wantConfigureCalls : 1 ,
201236 wantErr : true ,
202237 },
238+ {
239+ name : "configures library with error message in response" ,
240+ api : "some/api" ,
241+ repo : newTestGitRepo (t ),
242+ state : & config.LibrarianState {
243+ Libraries : []* config.LibraryState {
244+ {
245+ ID : "some-library" ,
246+ APIs : []* config.API {{Path : "some/api" }},
247+ },
248+ },
249+ },
250+ container : & mockContainerClient {
251+ wantErrorMsg : true ,
252+ },
253+ wantConfigureCalls : 1 ,
254+ wantErr : true ,
255+ },
203256 {
204257 name : "configures library with no response" ,
205258 api : "some/api" ,
@@ -212,7 +265,9 @@ func TestRunConfigureCommand(t *testing.T) {
212265 },
213266 },
214267 },
215- container : & mockContainerClient {},
268+ container : & mockContainerClient {
269+ noConfigureResponse : true ,
270+ },
216271 wantConfigureCalls : 1 ,
217272 wantErr : true ,
218273 },
@@ -249,7 +304,8 @@ func TestRunConfigureCommand(t *testing.T) {
249304 containerClient : test .container ,
250305 }
251306
252- if test .name == "configures library" {
307+ if test .name == "configures library successfully" ||
308+ test .name == "configures library with error message in response" {
253309 if err := os .MkdirAll (filepath .Join (cfg .APISource , test .api ), 0755 ); err != nil {
254310 t .Fatal (err )
255311 }
@@ -258,19 +314,6 @@ func TestRunConfigureCommand(t *testing.T) {
258314 if err := os .WriteFile (filepath .Join (cfg .APISource , test .api , "example_service_v2.yaml" ), data , 0755 ); err != nil {
259315 t .Fatal (err )
260316 }
261-
262- // Write a configure-response.json because it is required by configure
263- // command.
264- if err := os .MkdirAll (filepath .Join (r .repo .GetDir (), config .LibrarianDir ), 0755 ); err != nil {
265- t .Fatal (err )
266- }
267-
268- libraryStr := fmt .Sprintf (`{
269- "ID": "%s"
270- }` , test .state .Libraries [0 ].ID )
271- if err := os .WriteFile (filepath .Join (r .repo .GetDir (), config .LibrarianDir , config .ConfigureResponse ), []byte (libraryStr ), 0755 ); err != nil {
272- t .Fatal (err )
273- }
274317 }
275318
276319 if test .name == "configures library with no response" ||
@@ -819,6 +862,28 @@ func TestGenerateScenarios(t *testing.T) {
819862 build : true ,
820863 wantErr : true ,
821864 },
865+ {
866+ name : "generate single existing library with error message in response" ,
867+ api : "some/api" ,
868+ library : "some-library" ,
869+ repo : newTestGitRepo (t ),
870+ state : & config.LibrarianState {
871+ Image : "gcr.io/test/image:v1.2.3" ,
872+ Libraries : []* config.LibraryState {
873+ {
874+ ID : "some-library" ,
875+ APIs : []* config.API {{Path : "some/api" }},
876+ },
877+ },
878+ },
879+ container : & mockContainerClient {
880+ wantErrorMsg : true ,
881+ },
882+ ghClient : & mockGitHubClient {},
883+ wantGenerateCalls : 1 ,
884+ wantConfigureCalls : 0 ,
885+ wantErr : true ,
886+ },
822887 {
823888 name : "generate all libraries configured in state" ,
824889 repo : newTestGitRepo (t ),
0 commit comments