(t *testing.T)
| 9 | ) |
| 10 | |
| 11 | func 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 | }, |
nothing calls this directly
no test coverage detected