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

Function TestAsObject

expr/types_test.go:5–69  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

3import "testing"
4
5func TestAsObject(t *testing.T) {
6 var (
7 object = &Object{
8 &NamedAttributeExpr{
9 Name: "foo",
10 Attribute: &AttributeExpr{
11 Type: String,
12 },
13 },
14 }
15 objectUserType = &UserTypeExpr{
16 AttributeExpr: &AttributeExpr{
17 Type: object,
18 },
19 }
20 notObjectUserType = &UserTypeExpr{
21 AttributeExpr: &AttributeExpr{
22 Type: Boolean,
23 },
24 }
25 objectResultType = &ResultTypeExpr{
26 UserTypeExpr: objectUserType,
27 }
28 notObjectResultType = &ResultTypeExpr{
29 UserTypeExpr: notObjectUserType,
30 }
31 )
32 cases := map[string]struct {
33 dt DataType
34 expected *Object
35 }{
36 "object user type": {
37 dt: objectUserType,
38 expected: object,
39 },
40 "not object user type": {
41 dt: notObjectUserType,
42 expected: nil,
43 },
44 "object result type": {
45 dt: objectResultType,
46 expected: object,
47 },
48 "not object result type": {
49 dt: notObjectResultType,
50 expected: nil,
51 },
52 "object": {
53 dt: object,
54 expected: object,
55 },
56 "not object": {
57 dt: Boolean,
58 expected: nil,
59 },
60 }
61
62 for k, tc := range cases {

Callers

nothing calls this directly

Calls 2

AsObjectFunction · 0.85
EqualFunction · 0.85

Tested by

no test coverage detected