Add tests for expe.ServiceExpr.Method()
@@ -7,6 +7,42 @@ import (
"goa.design/goa/eval"
)
+func TestServiceExprMethod(t *testing.T) {
+ var (
+ methodFoo = &MethodExpr{
+ Name: "foo",
+ }
+ methodBar = &MethodExpr{
+ Name: "bar",
+ }
+ )
+ cases := map[string]struct {
+ name string
+ expected *MethodExpr
+ }{
+ "exist": {
+ name: "foo",
+ expected: methodFoo,
+ },
+ "not exist": {
+ name: "baz",
+ expected: nil,
+ },
+ }
+
+ for k, tc := range cases {
+ s := ServiceExpr{
+ Methods: []*MethodExpr{
+ methodFoo,
+ methodBar,
+ },
+ }
+ if actual := s.Method(tc.name); actual != tc.expected {
+ t.Errorf("%s: got %#v, expected %#v", k, actual, tc.expected)
+ }
+ }
+}
+
func TestServiceExprValidate(t *testing.T) {
const (
identifier = "result"
