@@ -19,6 +19,7 @@ import (
1919 "testing"
2020
2121 "github.com/google/go-cmp/cmp"
22+ "github.com/google/go-cmp/cmp/cmpopts"
2223 "github.com/googleapis/librarian/internal/sidekick/internal/api"
2324 "github.com/googleapis/librarian/internal/sidekick/internal/api/apitest"
2425)
@@ -57,6 +58,7 @@ func TestMapFields(t *testing.T) {
5758 Deprecated : true ,
5859 Typez : api .MESSAGE_TYPE ,
5960 TypezID : "$map<string, string>" ,
61+ Map : true ,
6062 },
6163 },
6264 }
@@ -125,6 +127,7 @@ func TestMapFieldWithObjectValues(t *testing.T) {
125127 Deprecated : true ,
126128 Typez : api .MESSAGE_TYPE ,
127129 TypezID : "$map<string, .package.SomeOtherMessage>" ,
130+ Map : true ,
128131 },
129132 },
130133 }
@@ -200,6 +203,7 @@ func TestMapFieldWithEnumValues(t *testing.T) {
200203 Deprecated : true ,
201204 Typez : api .MESSAGE_TYPE ,
202205 TypezID : "$map<string, .package.Message.enumMapField>" ,
206+ Map : true ,
203207 },
204208 },
205209 }
@@ -290,9 +294,9 @@ func TestMapScalarTypes(t *testing.T) {
290294 input := & schema {
291295 Properties : []* property {
292296 {
293- Name : "enumMapField " ,
297+ Name : "mapField " ,
294298 Schema : & schema {
295- Description : "The description for enumMapField ." ,
299+ Description : "The description for mapField ." ,
296300 Type : "object" ,
297301 AdditionalProperties : & schema {
298302 Type : test .Type ,
@@ -307,8 +311,18 @@ func TestMapScalarTypes(t *testing.T) {
307311 t .Error (err )
308312 continue
309313 }
310- if len (message .Fields ) != 1 {
311- t .Errorf ("expected exactly one field, got=%v" , message .Fields )
314+ wantFields := []* api.Field {
315+ {
316+ Name : "mapField" ,
317+ JSONName : "mapField" ,
318+ ID : ".package.Message.mapField" ,
319+ Documentation : "The description for mapField." ,
320+ Typez : api .MESSAGE_TYPE ,
321+ Map : true ,
322+ },
323+ }
324+ if diff := cmp .Diff (wantFields , message .Fields , cmpopts .IgnoreFields (api.Field {}, "TypezID" )); diff != "" {
325+ t .Errorf ("mismatch (-want, +got):\n %s" , diff )
312326 continue
313327 }
314328 mapMessage , ok := model .State .MessageByID [message .Fields [0 ].TypezID ]
0 commit comments