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:
@@ -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{
|
||||
|
||||
Reference in New Issue
Block a user