Skip to content

Commit 196e67a

Browse files
committed
Add a test case for HTTP routes
1 parent 219bccb commit 196e67a

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

expr/http_endpoint_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package expr_test
22

33
import (
4+
"strings"
45
"testing"
56

67
"goa.design/goa/v3/eval"
@@ -19,14 +20,15 @@ func TestHTTPRouteValidation(t *testing.T) {
1920
{"disallow-response-body", testdata.DisallowResponseBodyHeadDSL, `route HEAD "/" of service "DisallowResponseBody" HTTP endpoint "Method": HTTP status 200: Response body defined for HEAD method which does not allow response body.
2021
route HEAD "/" of service "DisallowResponseBody" HTTP endpoint "Method": HTTP status 404: Response body defined for HEAD method which does not allow response body.`,
2122
},
23+
{"invalid", testdata.InvalidRouteDSL, "invalid use of POST in service \"InvalidRoute\""},
2224
}
2325
for _, c := range cases {
2426
t.Run(c.Name, func(t *testing.T) {
2527
if c.Error == "" {
2628
expr.RunDSL(t, c.DSL)
2729
} else {
2830
err := expr.RunInvalidDSL(t, c.DSL)
29-
if err.Error() != c.Error {
31+
if !strings.HasSuffix(err.Error(), c.Error) {
3032
t.Errorf("got error %q\nexpected %q", err.Error(), c.Error)
3133
}
3234
}

expr/testdata/endpoint_dsls.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,14 @@ var DisallowResponseBodyHeadDSL = func() {
5252
})
5353
}
5454

55+
var InvalidRouteDSL = func() {
56+
Service("InvalidRoute", func() {
57+
HTTP(func() {
58+
POST("/{id}")
59+
})
60+
})
61+
}
62+
5563
var EndpointWithParentDSL = func() {
5664
Service("Parent", func() {
5765
Method("show", func() {

0 commit comments

Comments
 (0)