@@ -20,11 +20,18 @@ import (
2020 "github.com/google/go-cmp/cmp"
2121 "github.com/google/go-cmp/cmp/cmpopts"
2222 "github.com/googleapis/librarian/internal/sidekick/internal/api"
23+ "github.com/googleapis/librarian/internal/sidekick/internal/config"
2324)
2425
2526func TestDisco_Parse (t * testing.T ) {
26- // Mixing Compute and Secret Manager like this is fine in tests.
27- got , err := ParseDisco (discoSourceFile , secretManagerYamlFullPath , map [string ]string {})
27+ cfg := & config.Config {
28+ General : config.GeneralConfig {
29+ // Mixing Compute and Secret Manager like this is fine in tests.
30+ SpecificationSource : discoSourceFile ,
31+ ServiceConfig : secretManagerYamlFullPath ,
32+ },
33+ }
34+ got , err := ParseDisco (cfg )
2835 if err != nil {
2936 t .Fatal (err )
3037 }
@@ -47,10 +54,16 @@ func TestDisco_Parse(t *testing.T) {
4754}
4855
4956func TestDisco_FindSources (t * testing.T ) {
50- got , err := ParseDisco (discoSourceFileRelative , "" , map [string ]string {
51- "test-root" : testdataDir ,
52- "roots" : "undefined,test" ,
53- })
57+ cfg := & config.Config {
58+ General : config.GeneralConfig {
59+ SpecificationSource : discoSourceFileRelative ,
60+ },
61+ Source : map [string ]string {
62+ "test-root" : testdataDir ,
63+ "roots" : "undefined,test" ,
64+ },
65+ }
66+ got , err := ParseDisco (cfg )
5467 if err != nil {
5568 t .Fatal (err )
5669 }
@@ -70,7 +83,12 @@ func TestDisco_FindSources(t *testing.T) {
7083}
7184
7285func TestDisco_ParseNoServiceConfig (t * testing.T ) {
73- got , err := ParseDisco (discoSourceFile , "" , map [string ]string {})
86+ cfg := & config.Config {
87+ General : config.GeneralConfig {
88+ SpecificationSource : discoSourceFile ,
89+ },
90+ }
91+ got , err := ParseDisco (cfg )
7492 if err != nil {
7593 t .Fatal (err )
7694 }
@@ -89,7 +107,12 @@ func TestDisco_ParseNoServiceConfig(t *testing.T) {
89107}
90108
91109func TestDisco_ParsePagination (t * testing.T ) {
92- model , err := ParseDisco (discoSourceFile , "" , map [string ]string {})
110+ cfg := & config.Config {
111+ General : config.GeneralConfig {
112+ SpecificationSource : discoSourceFile ,
113+ },
114+ }
115+ model , err := ParseDisco (cfg )
93116 if err != nil {
94117 t .Fatal (err )
95118 }
@@ -113,7 +136,12 @@ func TestDisco_ParsePagination(t *testing.T) {
113136}
114137
115138func TestDisco_ParsePaginationAggregate (t * testing.T ) {
116- model , err := ParseDisco (discoSourceFile , "" , map [string ]string {})
139+ cfg := & config.Config {
140+ General : config.GeneralConfig {
141+ SpecificationSource : discoSourceFile ,
142+ },
143+ }
144+ model , err := ParseDisco (cfg )
117145 if err != nil {
118146 t .Fatal (err )
119147 }
@@ -137,7 +165,12 @@ func TestDisco_ParsePaginationAggregate(t *testing.T) {
137165}
138166
139167func TestDisco_ParseDeprecatedEnum (t * testing.T ) {
140- model , err := ParseDisco (discoSourceFile , "" , map [string ]string {})
168+ cfg := & config.Config {
169+ General : config.GeneralConfig {
170+ SpecificationSource : discoSourceFile ,
171+ },
172+ }
173+ model , err := ParseDisco (cfg )
141174 if err != nil {
142175 t .Fatal (err )
143176 }
@@ -157,15 +190,13 @@ func TestDisco_ParseDeprecatedEnum(t *testing.T) {
157190}
158191
159192func TestDisco_ParseBadFiles (t * testing.T ) {
160- if _ , err := ParseDisco ("-invalid-file-name-" , secretManagerYamlFullPath , map [string ]string {}); err == nil {
161- t .Fatalf ("expected error with missing source file" )
162- }
163-
164- if _ , err := ParseDisco (discoSourceFile , "-invalid-file-name-" , map [string ]string {}); err == nil {
165- t .Fatalf ("expected error with missing service config yaml file" )
166- }
167-
168- if _ , err := ParseDisco (secretManagerYamlFullPath , secretManagerYamlFullPath , map [string ]string {}); err == nil {
169- t .Fatalf ("expected error with invalid source file contents" )
193+ for _ , cfg := range []config.GeneralConfig {
194+ {SpecificationSource : "-invalid-file-name-" , ServiceConfig : secretManagerYamlFullPath },
195+ {SpecificationSource : discoSourceFile , ServiceConfig : "-invalid-file-name-" },
196+ {SpecificationSource : secretManagerYamlFullPath , ServiceConfig : secretManagerYamlFullPath },
197+ } {
198+ if got , err := ParseDisco (& config.Config {General : cfg }); err == nil {
199+ t .Fatalf ("expected error with missing source file, got=%v" , got )
200+ }
170201 }
171202}
0 commit comments