|
9 | 9 | "github.com/DevLabFoundry/configmanager/v3/internal/lexer" |
10 | 10 | "github.com/DevLabFoundry/configmanager/v3/internal/log" |
11 | 11 | "github.com/DevLabFoundry/configmanager/v3/internal/parser" |
12 | | - "github.com/DevLabFoundry/configmanager/v3/internal/store" |
13 | 12 | ) |
14 | 13 |
|
15 | 14 | var lexerSource = lexer.Source{FileName: "bar", FullPath: "/foo/bar"} |
@@ -188,100 +187,100 @@ func Test_Parse_should_pass_with_metadata_end_tag(t *testing.T) { |
188 | 187 | } |
189 | 188 | } |
190 | 189 |
|
191 | | -func Test_Parse_ParseMetadata(t *testing.T) { |
| 190 | +// func Test_Parse_ParseMetadata(t *testing.T) { |
192 | 191 |
|
193 | | - ttests := map[string]struct { |
194 | | - input string |
195 | | - typ *store.SecretsMgrConfig |
196 | | - }{ |
197 | | - "without keysPath": { |
198 | | - `AWSSECRETS:///foo[version=1.2.3]`, |
199 | | - &store.SecretsMgrConfig{}, |
200 | | - }, |
201 | | - "with keysPath": { |
202 | | - `AWSSECRETS:///foo|path.one[version=1.2.3]`, |
203 | | - &store.SecretsMgrConfig{}, |
204 | | - }, |
205 | | - "nestled in text": { |
206 | | - `someQ=AWSPARAMSTR:///path/queryparam|p1[version=1.2.3]&anotherQ`, |
207 | | - &store.SecretsMgrConfig{}, |
208 | | - }, |
209 | | - } |
210 | | - for name, tt := range ttests { |
211 | | - t.Run(name, func(t *testing.T) { |
212 | | - lexerSource.Input = tt.input |
213 | | - cfg := config.NewConfig() |
214 | | - l := lexer.New(lexerSource, *cfg) |
215 | | - p := parser.New(l, cfg).WithLogger(log.New(os.Stderr)) |
216 | | - parsed, errs := p.Parse() |
217 | | - if len(errs) > 0 { |
218 | | - t.Fatalf("%v", errs) |
219 | | - } |
| 192 | +// ttests := map[string]struct { |
| 193 | +// input string |
| 194 | +// typ *store.SecretsMgrConfig |
| 195 | +// }{ |
| 196 | +// "without keysPath": { |
| 197 | +// `AWSSECRETS:///foo[version=1.2.3]`, |
| 198 | +// &store.SecretsMgrConfig{}, |
| 199 | +// }, |
| 200 | +// "with keysPath": { |
| 201 | +// `AWSSECRETS:///foo|path.one[version=1.2.3]`, |
| 202 | +// &store.SecretsMgrConfig{}, |
| 203 | +// }, |
| 204 | +// "nestled in text": { |
| 205 | +// `someQ=AWSPARAMSTR:///path/queryparam|p1[version=1.2.3]&anotherQ`, |
| 206 | +// &store.SecretsMgrConfig{}, |
| 207 | +// }, |
| 208 | +// } |
| 209 | +// for name, tt := range ttests { |
| 210 | +// t.Run(name, func(t *testing.T) { |
| 211 | +// lexerSource.Input = tt.input |
| 212 | +// cfg := config.NewConfig() |
| 213 | +// l := lexer.New(lexerSource, *cfg) |
| 214 | +// p := parser.New(l, cfg).WithLogger(log.New(os.Stderr)) |
| 215 | +// parsed, errs := p.Parse() |
| 216 | +// if len(errs) > 0 { |
| 217 | +// t.Fatalf("%v", errs) |
| 218 | +// } |
220 | 219 |
|
221 | | - for _, p := range parsed { |
222 | | - if err := p.ParsedToken.ParseMetadata(tt.typ); err != nil { |
223 | | - t.Fatal(err) |
224 | | - } |
225 | | - if tt.typ.Version != "1.2.3" { |
226 | | - t.Errorf("got %v wanted 1.2.3", tt.typ.Version) |
227 | | - } |
228 | | - } |
229 | | - }) |
230 | | - } |
231 | | -} |
| 220 | +// for _, p := range parsed { |
| 221 | +// if err := p.ParsedToken.ParseMetadata(tt.typ); err != nil { |
| 222 | +// t.Fatal(err) |
| 223 | +// } |
| 224 | +// if tt.typ.Version != "1.2.3" { |
| 225 | +// t.Errorf("got %v wanted 1.2.3", tt.typ.Version) |
| 226 | +// } |
| 227 | +// } |
| 228 | +// }) |
| 229 | +// } |
| 230 | +// } |
232 | 231 |
|
233 | | -func Test_Parse_Path_Keys_WithParsedMetadat(t *testing.T) { |
| 232 | +// func Test_Parse_Path_Keys_WithParsedMetadat(t *testing.T) { |
234 | 233 |
|
235 | | - ttests := map[string]struct { |
236 | | - input string |
237 | | - typ *store.SecretsMgrConfig |
238 | | - wantSanitizedPath string |
239 | | - wantKeyPath string |
240 | | - }{ |
241 | | - "without keysPath": { |
242 | | - `AWSSECRETS:///foo[version=1.2.3]`, |
243 | | - &store.SecretsMgrConfig{}, |
244 | | - "/foo", "", |
245 | | - }, |
246 | | - "with keysPath": { |
247 | | - `AWSSECRETS:///foo|path.one[version=1.2.3]`, |
248 | | - &store.SecretsMgrConfig{}, |
249 | | - "/foo", "path.one", |
250 | | - }, |
251 | | - "nestled in text": { |
252 | | - `someQ=AWSPARAMSTR:///path/queryparam|p1[version=1.2.3]&anotherQ`, |
253 | | - &store.SecretsMgrConfig{}, |
254 | | - "/path/queryparam", "p1", |
255 | | - }, |
256 | | - } |
257 | | - for name, tt := range ttests { |
258 | | - t.Run(name, func(t *testing.T) { |
259 | | - lexerSource.Input = tt.input |
260 | | - cfg := config.NewConfig() |
261 | | - l := lexer.New(lexerSource, *cfg) |
262 | | - p := parser.New(l, cfg).WithLogger(log.New(os.Stderr)) |
263 | | - parsed, errs := p.Parse() |
264 | | - if len(errs) > 0 { |
265 | | - t.Fatalf("%v", errs) |
266 | | - } |
| 234 | +// ttests := map[string]struct { |
| 235 | +// input string |
| 236 | +// typ *store.SecretsMgrConfig |
| 237 | +// wantSanitizedPath string |
| 238 | +// wantKeyPath string |
| 239 | +// }{ |
| 240 | +// "without keysPath": { |
| 241 | +// `AWSSECRETS:///foo[version=1.2.3]`, |
| 242 | +// &store.SecretsMgrConfig{}, |
| 243 | +// "/foo", "", |
| 244 | +// }, |
| 245 | +// "with keysPath": { |
| 246 | +// `AWSSECRETS:///foo|path.one[version=1.2.3]`, |
| 247 | +// &store.SecretsMgrConfig{}, |
| 248 | +// "/foo", "path.one", |
| 249 | +// }, |
| 250 | +// "nestled in text": { |
| 251 | +// `someQ=AWSPARAMSTR:///path/queryparam|p1[version=1.2.3]&anotherQ`, |
| 252 | +// &store.SecretsMgrConfig{}, |
| 253 | +// "/path/queryparam", "p1", |
| 254 | +// }, |
| 255 | +// } |
| 256 | +// for name, tt := range ttests { |
| 257 | +// t.Run(name, func(t *testing.T) { |
| 258 | +// lexerSource.Input = tt.input |
| 259 | +// cfg := config.NewConfig() |
| 260 | +// l := lexer.New(lexerSource, *cfg) |
| 261 | +// p := parser.New(l, cfg).WithLogger(log.New(os.Stderr)) |
| 262 | +// parsed, errs := p.Parse() |
| 263 | +// if len(errs) > 0 { |
| 264 | +// t.Fatalf("%v", errs) |
| 265 | +// } |
267 | 266 |
|
268 | | - for _, p := range parsed { |
269 | | - if p.ParsedToken.StoreToken() != tt.wantSanitizedPath { |
270 | | - t.Errorf("got %s want %s", p.ParsedToken.StoreToken(), tt.wantSanitizedPath) |
271 | | - } |
272 | | - if p.ParsedToken.LookupKeys() != tt.wantKeyPath { |
273 | | - t.Errorf("got %s want %s", p.ParsedToken.LookupKeys(), tt.wantKeyPath) |
274 | | - } |
275 | | - if err := p.ParsedToken.ParseMetadata(tt.typ); err != nil { |
276 | | - t.Fatal(err) |
277 | | - } |
278 | | - if tt.typ.Version != "1.2.3" { |
279 | | - t.Errorf("got %v wanted 1.2.3", tt.typ.Version) |
280 | | - } |
281 | | - } |
282 | | - }) |
283 | | - } |
284 | | -} |
| 267 | +// for _, p := range parsed { |
| 268 | +// if p.ParsedToken.StoreToken() != tt.wantSanitizedPath { |
| 269 | +// t.Errorf("got %s want %s", p.ParsedToken.StoreToken(), tt.wantSanitizedPath) |
| 270 | +// } |
| 271 | +// if p.ParsedToken.LookupKeys() != tt.wantKeyPath { |
| 272 | +// t.Errorf("got %s want %s", p.ParsedToken.LookupKeys(), tt.wantKeyPath) |
| 273 | +// } |
| 274 | +// if err := p.ParsedToken.ParseMetadata(tt.typ); err != nil { |
| 275 | +// t.Fatal(err) |
| 276 | +// } |
| 277 | +// if tt.typ.Version != "1.2.3" { |
| 278 | +// t.Errorf("got %v wanted 1.2.3", tt.typ.Version) |
| 279 | +// } |
| 280 | +// } |
| 281 | +// }) |
| 282 | +// } |
| 283 | +// } |
285 | 284 |
|
286 | 285 | func testHelperGenDocBlock(t *testing.T, stmtBlock parser.ConfigManagerTokenBlock, tokenType config.ImplementationPrefix, tokenValue, keysLookupPath string) bool { |
287 | 286 | t.Helper() |
|
0 commit comments