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

Function TestMetaExpr_Last

expr/root_test.go:49–100  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

47}
48
49func TestMetaExpr_Last(t *testing.T) {
50 tt := map[string]struct {
51 meta MetaExpr
52 value string
53 ok bool
54 }{
55 "no-key": {
56 MetaExpr{},
57 "",
58 false,
59 },
60 "key-no-values": {
61 MetaExpr{
62 "test:key": []string{},
63 },
64 "",
65 false,
66 },
67 "key-with-one-value": {
68 MetaExpr{
69 "test:key": []string{
70 "value-one",
71 },
72 },
73 "value-one",
74 true,
75 },
76 "key-with-multiple-values": {
77 MetaExpr{
78 "test:key": []string{
79 "value-one",
80 "value-two",
81 "value-n",
82 },
83 },
84 "value-n",
85 true,
86 },
87 }
88
89 for name, tc := range tt {
90 t.Run(name, func(t *testing.T) {
91 value, ok := tc.meta.Last("test:key")
92 if tc.ok != ok {
93 t.Errorf("expected ok to be %v, got %v", tc.ok, ok)
94 }
95 if tc.value != value {
96 t.Errorf("expected value to be %s, got %s", value, value)
97 }
98 })
99 }
100}

Callers

nothing calls this directly

Calls 2

LastMethod · 0.80
RunMethod · 0.45

Tested by

no test coverage detected