Add some better tests for use_struct_references (#273)

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.
This commit is contained in:
Ben Kraft
2023-05-06 14:12:00 -07:00
committed by GitHub
parent d09d25ef9d
commit 9b2f16c088
4 changed files with 618 additions and 69 deletions
+21 -2
View File
@@ -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{