ceph-csi/vendor/github.com/googleapis/gnostic/generate-gnostic/generate-extension_test.go
Serguei Bezverkhi 7b24313bd6 vendor files
2018-01-10 13:42:26 -05:00

53 lines
1.1 KiB
Go

package main
import (
"io/ioutil"
"os"
"os/exec"
"testing"
)
func TestErrorExtensionGeneratorUnsupportedPrimitive(t *testing.T) {
var err error
output, err := exec.Command(
"generator",
"--extension",
"test/x-unsupportedprimitives.json",
"--out_dir=/tmp",
).Output()
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(
"generator",
"--extension",
"test/x-extension-name-collision.json",
"--out_dir=/tmp",
).Output()
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)
}
}