Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions cors/generate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"goa.design/goa/v3/codegen"
"goa.design/goa/v3/codegen/service"
"goa.design/goa/v3/eval"
"goa.design/goa/v3/expr"
httpcodegen "goa.design/goa/v3/http/codegen"

"goa.design/plugins/v3/cors"
Expand Down Expand Up @@ -43,11 +42,11 @@ func NewCORSHandler() http.Handler {
}
for _, c := range cases {
t.Run(c.Name, func(t *testing.T) {
httpcodegen.RunHTTPDSL(t, c.DSL)
services := httpcodegen.NewServicesData(service.NewServicesData(expr.Root), expr.Root.API.HTTP)
root := httpcodegen.RunHTTPDSL(t, c.DSL)
services := httpcodegen.NewServicesData(service.NewServicesData(root), root.API.HTTP)
fs := httpcodegen.ServerFiles("", services)
require.Len(t, fs, c.CodeGenCount)
cors.Generate("", []eval.Root{expr.Root}, fs)
cors.Generate("", []eval.Root{root}, fs)
expectedCodeIndex := -1
for _, f := range fs {
if filepath.Base(f.Path) != "server.go" {
Expand Down
9 changes: 4 additions & 5 deletions goakit/encode_decode_files_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"goa.design/goa/v3/codegen"
"goa.design/goa/v3/expr"
httpcodegen "goa.design/goa/v3/http/codegen"

"goa.design/plugins/v3/goakit/testdata"
Expand Down Expand Up @@ -67,8 +66,8 @@ func TestServerEncodeDecode(t *testing.T) {
}
for name, c := range cases {
t.Run(name, func(t *testing.T) {
httpcodegen.RunHTTPDSL(t, c.DSL)
fs := EncodeDecodeFiles("", expr.Root)
root := httpcodegen.RunHTTPDSL(t, c.DSL)
fs := EncodeDecodeFiles("", root)
require.Len(t, fs, 2)
var found bool
for _, f := range fs {
Expand Down Expand Up @@ -126,8 +125,8 @@ func TestClientEncodeDecode(t *testing.T) {
}
for name, c := range cases {
t.Run(name, func(t *testing.T) {
httpcodegen.RunHTTPDSL(t, c.DSL)
fs := EncodeDecodeFiles("", expr.Root)
root := httpcodegen.RunHTTPDSL(t, c.DSL)
fs := EncodeDecodeFiles("", root)
require.Len(t, fs, 2)
var found bool
for _, f := range fs {
Expand Down
13 changes: 6 additions & 7 deletions goakit/generate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"goa.design/goa/v3/codegen"
"goa.design/goa/v3/codegen/generator"
"goa.design/goa/v3/eval"
"goa.design/goa/v3/expr"
httpcodegen "goa.design/goa/v3/http/codegen"
"goa.design/plugins/v3/goakit/testdata"
)
Expand All @@ -25,8 +24,8 @@ func TestGenerate(t *testing.T) {
}
for name, c := range cases {
t.Run(name, func(t *testing.T) {
httpcodegen.RunHTTPDSL(t, c.DSL)
roots := []eval.Root{expr.Root}
root := httpcodegen.RunHTTPDSL(t, c.DSL)
roots := []eval.Root{root}
files := generateFiles(t, roots)
newFiles, err := Generate("", roots, files)
if err != nil {
Expand All @@ -49,8 +48,8 @@ func TestGoakitify(t *testing.T) {
}
for name, dsl := range cases {
t.Run(name, func(t *testing.T) {
httpcodegen.RunHTTPDSL(t, dsl)
roots := []eval.Root{expr.Root}
root := httpcodegen.RunHTTPDSL(t, dsl)
roots := []eval.Root{root}
files := generateFiles(t, roots)
newFiles, err := Goakitify("", roots, files)
require.NoError(t, err)
Expand Down Expand Up @@ -111,8 +110,8 @@ func TestGoakitifyExample(t *testing.T) {
}
for name, c := range cases {
t.Run(name, func(t *testing.T) {
httpcodegen.RunHTTPDSL(t, c.DSL)
roots := []eval.Root{expr.Root}
root := httpcodegen.RunHTTPDSL(t, c.DSL)
roots := []eval.Root{root}
files := generateExamples(t, roots)
files, err := GoakitifyExample("", roots, files)
require.NoError(t, err)
Expand Down
5 changes: 2 additions & 3 deletions goakit/mount_files_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package goakit
import (
"testing"

"goa.design/goa/v3/expr"
httpcodegen "goa.design/goa/v3/http/codegen"
"goa.design/plugins/v3/goakit/testdata"
)
Expand Down Expand Up @@ -49,8 +48,8 @@ func TestMountFiles(t *testing.T) {
}
for name, c := range cases {
t.Run(name, func(t *testing.T) {
httpcodegen.RunHTTPDSL(t, c.DSL)
fs := MountFiles(expr.Root)
root := httpcodegen.RunHTTPDSL(t, c.DSL)
fs := MountFiles(root)
if len(fs) != 1 {
t.Fatalf("got %d files, expected 1", len(fs))
}
Expand Down
10 changes: 5 additions & 5 deletions i18n/generate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ func TestPrepare(t *testing.T) {
for _, c := range cases {
t.Run(c.Name, func(t *testing.T) {
os.Setenv("GOA_I18N", c.Locales)
httpcodegen.RunHTTPDSL(t, c.DSL)
root := httpcodegen.RunHTTPDSL(t, c.DSL)

roots, _ := eval.Context.Roots()
roots := []eval.Root{root}

// Expect Description to be empty
checkExpr(roots, &expr.ServiceExpr{}, func(se interface{}) {
Expand Down Expand Up @@ -63,11 +63,11 @@ func checkExpr(roots []eval.Root, t interface{}, cb func(se interface{})) {
func TestGenerate(t *testing.T) {
os.Setenv("GOA_I18N", "en,nl")

httpcodegen.RunHTTPDSL(t, testdata.SimpleI18nDSL)
roots, _ := eval.Context.Roots()
root := httpcodegen.RunHTTPDSL(t, testdata.SimpleI18nDSL)
roots := []eval.Root{root}
i18n.Prepare("", roots)

fs, _ := httpcodegen.OpenAPIFiles(expr.Root)
fs, _ := httpcodegen.OpenAPIFiles(root)
gfs, _ := i18n.Generate("", roots, fs)

if len(gfs) != 8 {
Expand Down
Loading