Clean up godoc (#82)
## Summary: Before open-sourcing, we want to make sure that (a) GoDoc looks reasonable, and (b) everything in the API is something we want to commit to. In this commit, I do some miscellaneous cleanup on both fronts; this does involve a few breaking changes to the programmatic API (better now than once it has users). In future commits, I'll likely move the documentation for `genqlient.yaml` and `@genqlient` to clearer places, and make `GenqlientDirective` private, such that GoDoc is really only for programmatic users. Fixes #25. Issue: https://github.com/Khan/genqlient/issues/25 ## Test plan: make check Author: benjaminjkraft Reviewers: dnerdy, benjaminjkraft, jvoll, aberkan, MiguelCastillo, mahtabsabet Required Reviewers: Approved By: dnerdy, jvoll Checks: ✅ Test (1.17), ✅ Test (1.16), ✅ Test (1.15), ✅ Test (1.14), ✅ Lint, ✅ Test (1.17), ✅ Test (1.16), ✅ Test (1.15), ✅ Test (1.14), ✅ Lint Pull Request URL: https://github.com/Khan/genqlient/pull/82
This commit is contained in:
+15
-15
@@ -145,43 +145,43 @@ func defaultConfig(t *testing.T) *Config {
|
||||
// configurations. It uses snapshots, just like TestGenerate.
|
||||
func TestGenerateWithConfig(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
fakeConfigFilename string
|
||||
config *Config // omits Schema and Operations, set below.
|
||||
name string
|
||||
baseDir string // relative to dataDir
|
||||
config *Config // omits Schema and Operations, set below.
|
||||
}{
|
||||
{"DefaultConfig", "genqlient.yaml", defaultConfig(t)},
|
||||
{"Subpackage", "genqlient.yaml", &Config{
|
||||
{"DefaultConfig", "", defaultConfig(t)},
|
||||
{"Subpackage", "", &Config{
|
||||
Generated: "mypkg/myfile.go",
|
||||
}},
|
||||
{"SubpackageConfig", "mypkg/genqlient.yaml", &Config{
|
||||
{"SubpackageConfig", "mypkg", &Config{
|
||||
Generated: "myfile.go", // (relative to genqlient.yaml)
|
||||
}},
|
||||
{"PackageName", "genqlient.yaml", &Config{
|
||||
{"PackageName", "", &Config{
|
||||
Generated: "myfile.go",
|
||||
Package: "mypkg",
|
||||
}},
|
||||
{"ExportOperations", "genqlient.yaml", &Config{
|
||||
{"ExportOperations", "", &Config{
|
||||
Generated: "generated.go",
|
||||
ExportOperations: "operations.json",
|
||||
}},
|
||||
{"CustomContext", "genqlient.yaml", &Config{
|
||||
{"CustomContext", "", &Config{
|
||||
Generated: "generated.go",
|
||||
ContextType: "github.com/Khan/genqlient/internal/testutil.MyContext",
|
||||
}},
|
||||
{"NoContext", "genqlient.yaml", &Config{
|
||||
{"NoContext", "", &Config{
|
||||
Generated: "generated.go",
|
||||
ContextType: "-",
|
||||
}},
|
||||
{"ClientGetter", "genqlient.yaml", &Config{
|
||||
{"ClientGetter", "", &Config{
|
||||
Generated: "generated.go",
|
||||
ClientGetter: "github.com/Khan/genqlient/internal/testutil.GetClientFromContext",
|
||||
}},
|
||||
{"ClientGetterCustomContext", "genqlient.yaml", &Config{
|
||||
{"ClientGetterCustomContext", "", &Config{
|
||||
Generated: "generated.go",
|
||||
ClientGetter: "github.com/Khan/genqlient/internal/testutil.GetClientFromMyContext",
|
||||
ContextType: "github.com/Khan/genqlient/internal/testutil.MyContext",
|
||||
}},
|
||||
{"ClientGetterNoContext", "genqlient.yaml", &Config{
|
||||
{"ClientGetterNoContext", "", &Config{
|
||||
Generated: "generated.go",
|
||||
ClientGetter: "github.com/Khan/genqlient/internal/testutil.GetClientFromNowhere",
|
||||
ContextType: "-",
|
||||
@@ -192,9 +192,9 @@ func TestGenerateWithConfig(t *testing.T) {
|
||||
|
||||
for _, test := range tests {
|
||||
config := test.config
|
||||
baseDir := filepath.Join(dataDir, test.baseDir)
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
err := config.ValidateAndFillDefaults(
|
||||
filepath.Join(dataDir, test.fakeConfigFilename))
|
||||
err := config.ValidateAndFillDefaults(baseDir)
|
||||
config.Schema = filepath.Join(dataDir, "schema.graphql")
|
||||
config.Operations = []string{filepath.Join(dataDir, sourceFilename)}
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user