github.com/woocoos/entco@v0.0.0-20240411071658-1e7b23d4df15/genx/entc_test.go (about) 1 package genx 2 3 import ( 4 "entgo.io/contrib/entgql" 5 "entgo.io/ent/entc" 6 "entgo.io/ent/entc/gen" 7 "github.com/stretchr/testify/assert" 8 "testing" 9 ) 10 11 func TestGlobalID(t *testing.T) { 12 tests := []struct { 13 name string 14 check entc.Option 15 }{ 16 { 17 name: "test", 18 check: func(g *gen.Config) error { 19 for _, template := range g.Templates { 20 if template.Name() == "gql_globalid" { 21 return nil 22 } 23 } 24 assert.FailNow(t, "template not found") 25 return nil 26 }, 27 }, 28 } 29 for _, tt := range tests { 30 t.Run(tt.name, func(t *testing.T) { 31 got := GlobalID() 32 cfg := &gen.Config{} 33 assert.NoError(t, got(cfg)) 34 }) 35 } 36 } 37 38 func TestReplaceGqlMutationInput(t *testing.T) { 39 tests := []struct { 40 name string 41 check entgql.ExtensionOption 42 }{ 43 { 44 name: "test", 45 check: func(g *entgql.Extension) error { 46 for _, template := range g.Templates() { 47 if template.Name() == "gql_mutation_input" { 48 return nil 49 } 50 } 51 assert.FailNow(t, "template not found") 52 return nil 53 }, 54 }, 55 } 56 for _, tt := range tests { 57 t.Run(tt.name, func(t *testing.T) { 58 got := ReplaceGqlMutationInput() 59 cfg := &entgql.Extension{} 60 assert.NoError(t, got(cfg)) 61 }) 62 } 63 }