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

Function TestTaggedAttribute

expr/attribute_test.go:10–104  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

8)
9
10func TestTaggedAttribute(t *testing.T) {
11 tagged := &AttributeExpr{
12 Type: &Object{
13 &NamedAttributeExpr{
14 Name: "Foo",
15 Attribute: &AttributeExpr{
16 Meta: MetaExpr{"foo": []string{"foo"}},
17 },
18 },
19 },
20 }
21 cases := map[string]struct {
22 a *AttributeExpr
23 expected string
24 }{
25 "tagged attribute": {
26 a: tagged,
27 expected: "Foo",
28 },
29 "not object": {
30 a: &AttributeExpr{
31 Type: Boolean,
32 },
33 expected: "",
34 },
35 "no meta": {
36 a: &AttributeExpr{
37 Type: &Object{
38 &NamedAttributeExpr{
39 Name: "Foo",
40 Attribute: &AttributeExpr{},
41 },
42 },
43 },
44 expected: "",
45 },
46 "extended": {
47 a: &AttributeExpr{
48 Type: &Object{
49 &NamedAttributeExpr{
50 Name: "bar",
51 Attribute: &AttributeExpr{Type: String},
52 },
53 },
54 Bases: []DataType{
55 &UserTypeExpr{
56 TypeName: "Extended",
57 AttributeExpr: tagged,
58 },
59 },
60 },
61 expected: "Foo",
62 },
63 "recursively extended": {
64 a: &AttributeExpr{
65 Type: &Object{
66 &NamedAttributeExpr{
67 Name: "bar",

Callers

nothing calls this directly

Calls 2

TaggedAttributeFunction · 0.85
RunMethod · 0.45

Tested by

no test coverage detected