MCPcopy Create free account
hub / github.com/goadesign/goa / TestMethod

Function TestMethod

dsl/method_test.go:11–113  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

9)
10
11func TestMethod(t *testing.T) {
12 const (
13 desc = "test description"
14 url = "test URL"
15 )
16 cases := map[string]struct {
17 DSL func()
18 Assert func(t *testing.T, s []*expr.MethodExpr)
19 }{
20 "a": {
21 func() {
22 Method("a", func() {})
23 },
24 func(t *testing.T, methods []*expr.MethodExpr) {
25 if len(methods) != 1 {
26 t.Fatalf("a: expected 1 method, got %d", len(methods))
27 }
28 method := methods[0]
29 if method.Name != "a" {
30 t.Fatalf("a: expected method name to be %s, got %s", "a", method.Name)
31 }
32 },
33 },
34 "b": {
35 func() {
36 Method("b", func() {
37 Docs(func() {
38 Description(desc)
39 URL(url)
40 })
41 })
42 },
43 func(t *testing.T, methods []*expr.MethodExpr) {
44 if len(methods) != 1 {
45 t.Fatalf("b: expected 1 method, got %d", len(methods))
46 }
47 method := methods[0]
48 if method.Docs == nil {
49 t.Fatalf("b: method docs is nil")
50 }
51 if method.Docs.Description != desc {
52 t.Errorf("b: expected docs description '%s' to match '%s' ", desc, method.Docs.Description)
53 }
54 if method.Docs.URL != url {
55 t.Errorf("b: expected docs url '%s' to match '%s' ", url, method.Docs.URL)
56 }
57 },
58 },
59 "c": {
60 func() {
61 Method("c", func() {
62 Payload(func() {
63 Description(desc)
64 Attribute("required", expr.String)
65 Required("required")
66 })
67 })
68 },

Callers

nothing calls this directly

Calls 12

AsObjectFunction · 0.92
ExecuteFunction · 0.92
MethodFunction · 0.85
DocsFunction · 0.85
DescriptionFunction · 0.85
URLFunction · 0.85
PayloadFunction · 0.85
AttributeFunction · 0.85
RequiredFunction · 0.85
IsRequiredMethod · 0.80
AttributeMethod · 0.65
RunMethod · 0.45

Tested by

no test coverage detected