github.com/ipld/go-ipld-prime@v0.21.0/schema/gen/go/testUnions_test.go (about) 1 package gengo 2 3 import ( 4 "runtime" 5 "testing" 6 7 "github.com/ipld/go-ipld-prime/node/tests" 8 "github.com/ipld/go-ipld-prime/schema" 9 ) 10 11 func TestUnionKeyed(t *testing.T) { 12 if runtime.GOOS != "darwin" { // TODO: enable parallelism on macos 13 t.Parallel() 14 } 15 16 for _, engine := range []*genAndCompileEngine{ 17 { 18 subtestName: "union-using-embed", 19 prefix: "union-keyed-using-embed", 20 adjCfg: AdjunctCfg{ 21 CfgUnionMemlayout: map[schema.TypeName]string{"StrStr": "embedAll"}, 22 }, 23 }, 24 { 25 subtestName: "union-using-ptr", 26 prefix: "union-keyed-using-interface", 27 adjCfg: AdjunctCfg{ 28 CfgUnionMemlayout: map[schema.TypeName]string{"StrStr": "interface"}, 29 }, 30 }, 31 } { 32 t.Run(engine.subtestName, func(t *testing.T) { 33 tests.SchemaTestUnionKeyed(t, engine) 34 }) 35 } 36 } 37 38 func TestUnionKeyedComplexChildren(t *testing.T) { 39 if runtime.GOOS != "darwin" { // TODO: enable parallelism on macos 40 t.Parallel() 41 } 42 43 for _, engine := range []*genAndCompileEngine{ 44 { 45 subtestName: "union-using-embed", 46 prefix: "union-keyed-complex-child-using-embed", 47 adjCfg: AdjunctCfg{ 48 CfgUnionMemlayout: map[schema.TypeName]string{"WheeUnion": "embedAll"}, 49 }, 50 }, 51 { 52 subtestName: "union-using-interface", 53 prefix: "union-keyed-complex-child-using-interface", 54 adjCfg: AdjunctCfg{ 55 CfgUnionMemlayout: map[schema.TypeName]string{"WheeUnion": "interface"}, 56 }, 57 }, 58 } { 59 t.Run(engine.subtestName, func(t *testing.T) { 60 tests.SchemaTestUnionKeyedComplexChildren(t, engine) 61 }) 62 } 63 } 64 65 func TestUnionKeyedReset(t *testing.T) { 66 if runtime.GOOS != "darwin" { // TODO: enable parallelism on macos 67 t.Parallel() 68 } 69 70 for _, engine := range []*genAndCompileEngine{ 71 { 72 subtestName: "union-using-embed", 73 prefix: "union-keyed-reset-using-embed", 74 adjCfg: AdjunctCfg{ 75 CfgUnionMemlayout: map[schema.TypeName]string{"WheeUnion": "embedAll"}, 76 }, 77 }, 78 { 79 subtestName: "union-using-interface", 80 prefix: "union-keyed-reset-using-interface", 81 adjCfg: AdjunctCfg{ 82 CfgUnionMemlayout: map[schema.TypeName]string{"WheeUnion": "interface"}, 83 }, 84 }, 85 } { 86 t.Run(engine.subtestName, func(t *testing.T) { 87 tests.SchemaTestUnionKeyedReset(t, engine) 88 }) 89 } 90 }