@@ -18,6 +18,8 @@ import (
1818 "testing"
1919
2020 "github.com/google/go-cmp/cmp"
21+ "github.com/google/go-cmp/cmp/cmpopts"
22+ "github.com/googleapis/librarian/internal/sidekick/internal/api"
2123)
2224
2325func TestDisco_Parse (t * testing.T ) {
@@ -86,12 +88,39 @@ func TestDisco_ParseNoServiceConfig(t *testing.T) {
8688 }
8789}
8890
91+ func TestDisco_ParsePagination (t * testing.T ) {
92+ model , err := ParseDisco (discoSourceFile , "" , map [string ]string {})
93+ if err != nil {
94+ t .Fatal (err )
95+ }
96+ wantID := "..zones.list"
97+ got , ok := model .State .MethodByID [wantID ]
98+ if ! ok {
99+ t .Fatalf ("expected method %s in the API model" , wantID )
100+ }
101+ wantPagination := & api.Field {
102+ Name : "pageToken" ,
103+ JSONName : "pageToken" ,
104+ Typez : api .STRING_TYPE ,
105+ TypezID : "string" ,
106+ Optional : true ,
107+ Synthetic : true ,
108+ }
109+ if diff := cmp .Diff (wantPagination , got .Pagination , cmpopts .IgnoreFields (api.Field {}, "Documentation" )); diff != "" {
110+ t .Errorf ("mismatch (-want, +got):\n %s" , diff )
111+ }
112+ }
113+
89114func TestDisco_ParseBadFiles (t * testing.T ) {
90115 if _ , err := ParseDisco ("-invalid-file-name-" , secretManagerYamlFullPath , map [string ]string {}); err == nil {
91- t .Fatalf ("expected error with invalid source file name " )
116+ t .Fatalf ("expected error with missing source file" )
92117 }
93118
94119 if _ , err := ParseDisco (discoSourceFile , "-invalid-file-name-" , map [string ]string {}); err == nil {
95- t .Fatalf ("expected error with invalid service config yaml file name" )
120+ t .Fatalf ("expected error with missing service config yaml file" )
121+ }
122+
123+ if _ , err := ParseDisco (secretManagerYamlFullPath , secretManagerYamlFullPath , map [string ]string {}); err == nil {
124+ t .Fatalf ("expected error with invalid source file contents" )
96125 }
97126}
0 commit comments