## Summary: I realized: - it's simpler to avoid the usual `cmd` and just put it all in the same directory - we don't need schema.json since GitHub now posts a schema in SDL format ## Test plan: make lint example Author: benjaminjkraft Reviewers: dnerdy, StevenACoffman, aberkan, jvoll, mahtabsabet, MiguelCastillo Required Reviewers: Approved By: dnerdy, StevenACoffman 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/89
34 lines
716 B
Go
34 lines
716 B
Go
package generate_test
|
|
|
|
import (
|
|
"os"
|
|
"os/exec"
|
|
"strings"
|
|
"testing"
|
|
|
|
"github.com/Khan/genqlient/internal/integration"
|
|
)
|
|
|
|
func TestGenerateExample(t *testing.T) {
|
|
integration.RunGenerateTest(t, "example/genqlient.yaml")
|
|
}
|
|
|
|
func TestRunExample(t *testing.T) {
|
|
if _, ok := os.LookupEnv("GITHUB_TOKEN"); !ok {
|
|
t.Skip("requires GITHUB_TOKEN to be set")
|
|
}
|
|
|
|
cmd := exec.Command("go", "run", "./example", "benjaminjkraft")
|
|
cmd.Dir = integration.RepoRoot(t)
|
|
out, err := cmd.CombinedOutput()
|
|
if err != nil {
|
|
t.Error(err)
|
|
}
|
|
|
|
got := strings.TrimSpace(string(out))
|
|
want := "benjaminjkraft is Ben Kraft created on 2009-08-03"
|
|
if got != want {
|
|
t.Errorf("output incorrect\ngot:\n%s\nwant:\n%s", got, want)
|
|
}
|
|
}
|