Repository impl & tests, move tests, comp. pk insert support
Go Tests / test (push) Failing after 8s
Go Tests / test (push) Failing after 8s
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
package simpleorm_test
|
||||
|
||||
import (
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
_ "github.com/mattn/go-sqlite3"
|
||||
log "gitlab.com/gdulai/simpleloglvl"
|
||||
)
|
||||
|
||||
type Test struct {
|
||||
ID int `sql:"pk"`
|
||||
Int64Field int64 `sql:"nn"`
|
||||
IntField int `sql:"nn"`
|
||||
StringField string `sql:"nn"`
|
||||
}
|
||||
|
||||
func (t Test) IsInsertable() bool {
|
||||
return t.ID == 0
|
||||
}
|
||||
|
||||
type TestWithFk struct {
|
||||
ID int `sql:"pk"`
|
||||
TestID int `sql:"nn;fk=Test.ID"`
|
||||
}
|
||||
|
||||
type TestWithFkAndFkId struct {
|
||||
ID int `sql:"pk"`
|
||||
TestID int `sql:"nn;fk=Test.ID;fk_id=custom_fk"`
|
||||
}
|
||||
|
||||
type TestWithCompositePk struct {
|
||||
ID int `sql:"nn;pk;"`
|
||||
Name string `sql:"nn;pk"`
|
||||
}
|
||||
|
||||
func (t TestWithCompositePk) IsInsertable() bool {
|
||||
return t.ID == 0 && t.Name == ""
|
||||
}
|
||||
|
||||
type TestWithCompositeFk struct {
|
||||
ID int `sql:"nn;pk"`
|
||||
CompositeFkId int `sql:"nn;fk=TestWithCompositePk.ID;"`
|
||||
CompositeFkName string `sql:"nn;fk=TestWithCompositePk.Name;"`
|
||||
}
|
||||
|
||||
type TestWithBool struct {
|
||||
ID int `sql:"pk"`
|
||||
BoolField bool `sql:"nn"`
|
||||
}
|
||||
|
||||
type TestWithTime struct {
|
||||
ID int `sql:"pk"`
|
||||
TimeField int64 `sql:"nn"`
|
||||
}
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
log.SetupLogs("Info")
|
||||
|
||||
code := m.Run()
|
||||
|
||||
os.Exit(code)
|
||||
}
|
||||
Reference in New Issue
Block a user