Skip to content

Commit

Permalink
Add some better tests for use_struct_references (#273)
Browse files Browse the repository at this point in the history
The test it was using was not really exercising things (maybe this was
before I added support for using different queries for config tests).
The new tests exercise a bit more, which is useful if you want to know
exactly what this option does. I also added tests where we mix with
`optional: pointer` since those interact a bit.
  • Loading branch information
benjaminjkraft authored May 6, 2023
1 parent d09d25e commit 9b2f16c
Show file tree
Hide file tree
Showing 4 changed files with 618 additions and 69 deletions.
23 changes: 21 additions & 2 deletions generate/generate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,28 @@ func TestGenerateWithConfig(t *testing.T) {
Generated: "generated.go",
ContextType: "github.com/Khan/genqlient/internal/testutil/junk---fun.name.MyContext",
}},
{"StructReferences", "", nil, &Config{
{"StructReferences", "", []string{"InputObject.graphql", "QueryWithStructs.graphql"}, &Config{
StructReferences: true,
Generated: "generated-structrefs.go",
Generated: "generated.go",
Bindings: map[string]*TypeBinding{
"Date": {
Type: "time.Time",
Marshaler: "github.com/Khan/genqlient/internal/testutil.MarshalDate",
Unmarshaler: "github.com/Khan/genqlient/internal/testutil.UnmarshalDate",
},
},
}},
{"StructReferencesAndOptionalPointer", "", []string{"InputObject.graphql", "QueryWithStructs.graphql"}, &Config{
StructReferences: true,
Optional: "pointer",
Generated: "generated.go",
Bindings: map[string]*TypeBinding{
"Date": {
Type: "time.Time",
Marshaler: "github.com/Khan/genqlient/internal/testutil.MarshalDate",
Unmarshaler: "github.com/Khan/genqlient/internal/testutil.UnmarshalDate",
},
},
}},
{"PackageBindings", "", nil, &Config{
PackageBindings: []*PackageBinding{
Expand Down

This file was deleted.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 9b2f16c

Please sign in to comment.