This commit is contained in:
+5
-17
@@ -3,26 +3,14 @@ package simpleorm_test
|
||||
import (
|
||||
"testing"
|
||||
|
||||
simpleorm "git.gdulai.com/gdulai/simpleorm"
|
||||
"git.gdulai.com/gdulai/simpleorm/exec"
|
||||
"git.gdulai.com/gdulai/simpleorm/repository"
|
||||
log "gitlab.com/gdulai/simpleloglvl"
|
||||
)
|
||||
|
||||
func repoTestSetup() (*simpleorm.ORM, *simpleorm.DBConnection) {
|
||||
conn := simpleorm.OpenConnection("sqlite3", "file:test.db")
|
||||
|
||||
orm := simpleorm.NewORM(Test{}, TestWithFk{}, TestWithFkAndFkId{},
|
||||
TestWithCompositePk{}, TestWithCompositeFk{})
|
||||
|
||||
exec.ExecuteDDL(conn, orm)
|
||||
|
||||
return orm, conn
|
||||
}
|
||||
|
||||
func TestRepoSelectAll(t *testing.T) {
|
||||
// GIVEN
|
||||
orm, conn := repoTestSetup()
|
||||
orm, conn := testSetup()
|
||||
defer cleanUp("test.db", conn)
|
||||
|
||||
testObj := Test{Int64Field: 54, IntField: 12, StringField: "asdf"}
|
||||
@@ -48,7 +36,7 @@ func TestRepoSelectAll(t *testing.T) {
|
||||
|
||||
func TestRepoSelectByPk(t *testing.T) {
|
||||
// GIVEN
|
||||
orm, conn := repoTestSetup()
|
||||
orm, conn := testSetup()
|
||||
defer cleanUp("test.db", conn)
|
||||
|
||||
testObj := Test{Int64Field: 54, IntField: 12, StringField: "asdf"}
|
||||
@@ -74,7 +62,7 @@ func TestRepoSelectByPk(t *testing.T) {
|
||||
|
||||
func TestRepoSelectByCompundPk(t *testing.T) {
|
||||
// GIVEN
|
||||
orm, conn := repoTestSetup()
|
||||
orm, conn := testSetup()
|
||||
defer cleanUp("test.db", conn)
|
||||
|
||||
testObj := TestWithCompositePk{ID: 42069, Name: "Test"}
|
||||
@@ -100,7 +88,7 @@ func TestRepoSelectByCompundPk(t *testing.T) {
|
||||
|
||||
func TestRepoSave(t *testing.T) {
|
||||
// GIVEN
|
||||
orm, conn := repoTestSetup()
|
||||
orm, conn := testSetup()
|
||||
defer cleanUp("test.db", conn)
|
||||
|
||||
testObj := &Test{Int64Field: 54, IntField: 12, StringField: "asdf"}
|
||||
@@ -121,7 +109,7 @@ func TestRepoSave(t *testing.T) {
|
||||
|
||||
func TestRepoDelete(t *testing.T) {
|
||||
// GIVEN
|
||||
orm, conn := repoTestSetup()
|
||||
orm, conn := testSetup()
|
||||
defer cleanUp("test.db", conn)
|
||||
|
||||
testObj := &Test{Int64Field: 54, IntField: 12, StringField: "asdf"}
|
||||
|
||||
Reference in New Issue
Block a user