@@ -179,4 +179,60 @@ java_grpc_library(
179179 if got .HasGAPIC () {
180180 t .Error ("HasGAPIC() = true; want false" )
181181 }
182+ }
183+
184+ func TestParse_missingSomeAttrs (t * testing.T ) {
185+ content := `
186+ java_gapic_library(
187+ name = "asset_java_gapic",
188+ service_yaml = "cloudasset_v1.yaml",
189+ )
190+ `
191+ tmpDir := t .TempDir ()
192+ buildPath := filepath .Join (tmpDir , "BUILD.bazel" )
193+ if err := os .WriteFile (buildPath , []byte (content ), 0644 ); err != nil {
194+ t .Fatalf ("failed to write test file: %v" , err )
195+ }
196+
197+ got , err := Parse (tmpDir )
198+ if err != nil {
199+ t .Fatalf ("Parse() failed: %v" , err )
200+ }
201+
202+ if got .GRPCServiceConfig () != "" {
203+ t .Errorf ("GRPCServiceConfig() = %q; want \" \" " , got .GRPCServiceConfig ())
204+ }
205+ if got .Transport () != "" {
206+ t .Errorf ("Transport() = %q; want \" \" " , got .Transport ())
207+ }
208+ if got .HasRESTNumericEnums () {
209+ t .Error ("HasRESTNumericEnums() = true; want false" )
210+ }
211+ }
212+
213+ func TestParse_invalidBoolAttr (t * testing.T ) {
214+ content := `
215+ java_gapic_library(
216+ name = "asset_java_gapic",
217+ rest_numeric_enums = "not-a-bool",
218+ )
219+ `
220+ tmpDir := t .TempDir ()
221+ buildPath := filepath .Join (tmpDir , "BUILD.bazel" )
222+ if err := os .WriteFile (buildPath , []byte (content ), 0644 ); err != nil {
223+ t .Fatalf ("failed to write test file: %v" , err )
224+ }
225+
226+ _ , err := Parse (tmpDir )
227+ if err == nil {
228+ t .Error ("Parse() succeeded; want error" )
229+ }
230+ }
231+
232+ func TestParse_noBuildFile (t * testing.T ) {
233+ tmpDir := t .TempDir ()
234+ _ , err := Parse (tmpDir )
235+ if err == nil {
236+ t .Error ("Parse() succeeded; want error" )
237+ }
182238}
0 commit comments