-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathmain_test.go
25 lines (20 loc) · 996 Bytes
/
main_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
package main
import (
"io/ioutil"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestGenerate(t *testing.T) {
schema, err := LoadSchema("testdata/github-schema.json")
require.NoError(t, err)
_, errs := Generate(schema, "test", []string{"testdata/github.go"}, "gql", "encoding/json")
require.Empty(t, errs)
}
func TestRun(t *testing.T) {
assert.Empty(t, Run(ioutil.Discard, "--pkg", "test", "-i", "testdata/github.go", "--schema", "testdata/github-schema.json"))
assert.NotEmpty(t, Run(ioutil.Discard, "-i", "testdata/github.go", "--schema", "testdata/github-schema.json"))
assert.NotEmpty(t, Run(ioutil.Discard, "--pkg", "test", "-i", "testdata/github.go"))
assert.NotEmpty(t, Run(ioutil.Discard, "--pkg", "test", "-i", "testdata/github.go", "--schema", "testdata/not-the-github-schema.json"))
assert.NotEmpty(t, Run(ioutil.Discard, "--pkg", "test", "-i", "testdata/github-schema.json", "--schema", "testdata/github-schema.json"))
}