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

Function TestAPIExprFinalize

expr/api_test.go:68–106  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

66}
67
68func TestAPIExprFinalize(t *testing.T) {
69 cases := map[string]struct {
70 api *APIExpr
71 expected []string
72 }{
73 "empty name, empty server": {
74 api: &APIExpr{},
75 expected: []string{"Default server for api"},
76 },
77 "empty server": {
78 api: &APIExpr{
79 Name: "my api",
80 },
81 expected: []string{"Default server for my api"},
82 },
83 "with server": {
84 api: &APIExpr{
85 Name: "my api",
86 Servers: []*ServerExpr{{Description: "my server"}},
87 },
88 expected: []string{"my server"},
89 },
90 }
91
92 for k, tc := range cases {
93 Root = &RootExpr{}
94 tc.api.Finalize()
95
96 if actual := tc.api.Servers; len(tc.expected) != len(actual) {
97 t.Errorf("%s: expected the number of servers to match %d got %d ", k, len(tc.expected), len(actual))
98 } else {
99 for i, v := range actual {
100 if v.Description != tc.expected[i] {
101 t.Errorf("%s: got %#v, expected %#v at index %d", k, v, tc.expected[i], i)
102 }
103 }
104 }
105 }
106}
107
108func TestApiExpr_Hash(t *testing.T) {
109 cases := map[string]struct {

Callers

nothing calls this directly

Calls 1

FinalizeMethod · 0.65

Tested by

no test coverage detected