-
Notifications
You must be signed in to change notification settings - Fork 251
/
generate-extension_test.go
58 lines (51 loc) · 1.3 KB
/
generate-extension_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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package main
import (
"io/ioutil"
"os"
"os/exec"
"testing"
)
func TestErrorExtensionGeneratorUnsupportedPrimitive(t *testing.T) {
var err error
output, err := exec.Command(
"generate-gnostic",
"--extension",
"test/x-unsupportedprimitives.json",
"--out_dir=/tmp",
).Output()
if err != nil {
t.Fatalf("error executing generate-gnostic: %v", err)
}
outputFile := "x-unsupportedprimitives.errors"
_ = ioutil.WriteFile(outputFile, output, 0644)
err = exec.Command("diff", outputFile, "test/errors/x-unsupportedprimitives.errors").Run()
if err != nil {
t.Logf("Diff failed: %+v", err)
t.FailNow()
} else {
// if the test succeeded, clean up
os.Remove(outputFile)
}
}
func TestErrorExtensionGeneratorNameCollision(t *testing.T) {
var err error
output, err := exec.Command(
"generate-gnostic",
"--extension",
"test/x-extension-name-collision.json",
"--out_dir=/tmp",
).Output()
if err != nil {
t.Fatalf("error executing generate-gnostic: %v", err)
}
outputFile := "x-extension-name-collision.errors"
_ = ioutil.WriteFile(outputFile, output, 0644)
err = exec.Command("diff", outputFile, "test/errors/x-extension-name-collision.errors").Run()
if err != nil {
t.Logf("Diff failed: %+v", err)
t.FailNow()
} else {
// if the test succeeded, clean up
os.Remove(outputFile)
}
}