-
Notifications
You must be signed in to change notification settings - Fork 804
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(convert): Support YAML anchors in plugin options (#2733)
- Loading branch information
1 parent
e465d0b
commit b3c3474
Showing
2 changed files
with
50 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package convert | ||
|
||
import ( | ||
"testing" | ||
|
||
"gopkg.in/yaml.v3" | ||
) | ||
|
||
const anchor = ` | ||
sql: | ||
- schema: query.sql | ||
queries: query.sql | ||
engine: postgresql | ||
codegen: | ||
- out: gateway/src/gateway/services/organization | ||
plugin: py | ||
options: &base-options | ||
query_parameter_limit: 1 | ||
package: gateway | ||
output_models_file_name: null | ||
emit_module: true | ||
emit_generators: false | ||
emit_async: true | ||
- schema: query.sql | ||
queries: query.sql | ||
engine: postgresql | ||
codegen: | ||
- out: gateway/src/gateway/services/project | ||
plugin: py | ||
options: *base-options | ||
` | ||
|
||
type config struct { | ||
SQL yaml.Node `yaml:"sql"` | ||
} | ||
|
||
func TestAlias(t *testing.T) { | ||
var a config | ||
err := yaml.Unmarshal([]byte(anchor), &a) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
if _, err := gen(&a.SQL); err != nil { | ||
t.Fatal(err) | ||
} | ||
} |