40 lines
784 B
Go
40 lines
784 B
Go
package main
|
|
|
|
import (
|
|
"testing"
|
|
|
|
core "dappco.re/go/core"
|
|
coreio "dappco.re/go/core/io"
|
|
)
|
|
|
|
func TestMain_Run_Good(t *testing.T) {
|
|
outDir := t.TempDir()
|
|
if err := run("../../testdata/swagger.v1.json", outDir); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
entries, err := coreio.Local.List(outDir)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
goFiles := 0
|
|
for _, e := range entries {
|
|
if core.HasSuffix(e.Name(), ".go") {
|
|
goFiles++
|
|
}
|
|
}
|
|
if goFiles == 0 {
|
|
t.Fatal("no .go files generated by run")
|
|
}
|
|
}
|
|
|
|
func TestMain_Run_Bad(t *testing.T) {
|
|
err := run("/does/not/exist/swagger.v1.json", t.TempDir())
|
|
if err == nil {
|
|
t.Fatal("expected error for invalid spec path")
|
|
}
|
|
if !core.Contains(err.Error(), "load spec") {
|
|
t.Fatalf("got error %q, expected load spec context", err.Error())
|
|
}
|
|
}
|