Skip to content

Commit 65e117a

Browse files
authored
Fix apipkg lookup in GenerateExample of testing plugin (#256)
* Fix apipkg lookup in GenerateExample of testing plugin * Fix apipkg lookup like Goa core
1 parent 70b1733 commit 65e117a

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

testing/generate.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,17 @@ func GenerateExample(genpkg string, roots []eval.Root, files []*codegen.File) ([
5151
if !ok {
5252
continue
5353
}
54+
services := service.NewServicesData(r)
55+
scope := codegen.NewNameScope()
56+
for _, svc := range r.Services {
57+
s := services.Get(svc.Name)
58+
if s == nil {
59+
continue
60+
}
61+
scope.Unique(s.PkgName)
62+
}
63+
apipkg := scope.Unique(strings.ToLower(codegen.Goify(r.API.Name, false)), "api")
5464
for _, svc := range r.Services {
55-
// Derive example implementation package name deterministically like Goa example generator
56-
snake := codegen.SnakeCase(svc.Name)
57-
apipkg := strings.ReplaceAll(snake, "_", "") + "api"
5865
if f := testcodegen.GenerateSuiteTopLevel(genpkg, apipkg, r, svc); f != nil {
5966
files = append(files, f)
6067
}

0 commit comments

Comments
 (0)