github.com/Ali-iotechsys/sqlboiler/v4@v4.0.0-20221208124957-6aec9a5f1f71/drivers/keys_test.go (about) 1 package drivers 2 3 import "testing" 4 5 func TestSQLColDefinitions(t *testing.T) { 6 t.Parallel() 7 8 cols := []Column{ 9 {Name: "one", Type: "int64"}, 10 {Name: "two", Type: "string"}, 11 {Name: "three", Type: "string"}, 12 } 13 14 defs := SQLColDefinitions(cols, []string{"one"}) 15 if len(defs) != 1 { 16 t.Error("wrong number of defs:", len(defs)) 17 } 18 if got := defs[0].String(); got != "one int64" { 19 t.Error("wrong def:", got) 20 } 21 22 defs = SQLColDefinitions(cols, []string{"one", "three"}) 23 if len(defs) != 2 { 24 t.Error("wrong number of defs:", len(defs)) 25 } 26 if got := defs[0].String(); got != "one int64" { 27 t.Error("wrong def:", got) 28 } 29 if got := defs[1].String(); got != "three string" { 30 t.Error("wrong def:", got) 31 } 32 } 33 34 func TestTypes(t *testing.T) { 35 t.Parallel() 36 37 defs := SQLColumnDefs{ 38 {Type: "thing1"}, 39 {Type: "thing2"}, 40 } 41 42 ret := defs.Types() 43 if ret[0] != "thing1" { 44 t.Error("wrong type:", ret[0]) 45 } 46 if ret[1] != "thing2" { 47 t.Error("wrong type:", ret[1]) 48 } 49 } 50 51 func TestNames(t *testing.T) { 52 t.Parallel() 53 54 defs := SQLColumnDefs{ 55 {Name: "thing1"}, 56 {Name: "thing2"}, 57 } 58 59 ret := defs.Names() 60 if ret[0] != "thing1" { 61 t.Error("wrong type:", ret[0]) 62 } 63 if ret[1] != "thing2" { 64 t.Error("wrong type:", ret[1]) 65 } 66 }