sqlboiler/bdb/keys_test.go

67 lines
1.2 KiB
Go
Raw Permalink Normal View History

package bdb
import "testing"
func TestSQLColDefinitions(t *testing.T) {
t.Parallel()
cols := []Column{
{Name: "one", Type: "int64"},
{Name: "two", Type: "string"},
{Name: "three", Type: "string"},
}
defs := SQLColDefinitions(cols, []string{"one"})
if len(defs) != 1 {
t.Error("wrong number of defs:", len(defs))
}
if got := defs[0].String(); got != "one int64" {
t.Error("wrong def:", got)
}
defs = SQLColDefinitions(cols, []string{"one", "three"})
if len(defs) != 2 {
t.Error("wrong number of defs:", len(defs))
}
if got := defs[0].String(); got != "one int64" {
t.Error("wrong def:", got)
}
if got := defs[1].String(); got != "three string" {
t.Error("wrong def:", got)
}
}
2016-08-15 16:38:26 +02:00
func TestTypes(t *testing.T) {
2016-08-18 14:29:14 +02:00
t.Parallel()
2016-08-15 16:38:26 +02:00
defs := SQLColumnDefs{
{Type: "thing1"},
{Type: "thing2"},
}
ret := defs.Types()
if ret[0] != "thing1" {
t.Error("wrong type:", ret[0])
}
if ret[1] != "thing2" {
t.Error("wrong type:", ret[1])
}
}
func TestNames(t *testing.T) {
2016-08-18 14:29:14 +02:00
t.Parallel()
2016-08-15 16:38:26 +02:00
defs := SQLColumnDefs{
{Name: "thing1"},
{Name: "thing2"},
}
ret := defs.Names()
if ret[0] != "thing1" {
t.Error("wrong type:", ret[0])
}
if ret[1] != "thing2" {
t.Error("wrong type:", ret[1])
}
}