(t *testing.T)
| 11 | ) |
| 12 | |
| 13 | func TestGoTransformUnion(t *testing.T) { |
| 14 | root := RunDSL(t, testdata.TestUnionDSL) |
| 15 | var ( |
| 16 | scope = NewNameScope() |
| 17 | |
| 18 | // types to test |
| 19 | unionString = root.UserType("Container").Attribute().Find("UnionString").Find("UnionString") |
| 20 | unionString2 = root.UserType("Container").Attribute().Find("UnionString2").Find("UnionString2") |
| 21 | unionStringInt = root.UserType("Container").Attribute().Find("UnionStringInt").Find("UnionStringInt") |
| 22 | unionStringInt2 = root.UserType("Container").Attribute().Find("UnionStringInt2").Find("UnionStringInt2") |
| 23 | unionSomeType = root.UserType("Container").Attribute().Find("UnionSomeType").Find("UnionSomeType") |
| 24 | unionSomeType2 = root.UserType("Container").Attribute().Find("UnionSomeType2").Find("UnionSomeType2") |
| 25 | defaultCtx = NewAttributeContext(false, false, true, "", scope) |
| 26 | ) |
| 27 | tc := []struct { |
| 28 | Name string |
| 29 | Source *expr.AttributeExpr |
| 30 | Target *expr.AttributeExpr |
| 31 | }{ |
| 32 | {"UnionString to UnionString2", unionString, unionString2}, |
| 33 | {"UnionStringInt to UnionStringInt2", unionStringInt, unionStringInt2}, |
| 34 | {"UnionSomeType to UnionSomeType2", unionSomeType, unionSomeType2}, |
| 35 | } |
| 36 | for _, c := range tc { |
| 37 | t.Run(c.Name, func(t *testing.T) { |
| 38 | code, _, err := GoTransform(c.Source, c.Target, "source", "target", defaultCtx, defaultCtx, "", true) |
| 39 | require.NoError(t, err) |
| 40 | code = FormatTestCode(t, "package foo\nfunc transform(){\n"+code+"}") |
| 41 | testutil.AssertGo(t, "testdata/golden/go_transform_union_"+c.Name+".go.golden", code) |
| 42 | }) |
| 43 | } |
| 44 | } |
| 45 | |
| 46 | func TestGoTransformUnionError(t *testing.T) { |
| 47 | root := RunDSL(t, testdata.TestUnionDSL) |
nothing calls this directly
no test coverage detected