web/webtest: remove DatabaseMigration to export DB
continuous-integration/drone the build was successful Details

This commit is contained in:
Geno 2021-06-22 20:44:24 +02:00
parent 56ef5276ce
commit 1848fccbef
4 changed files with 9 additions and 21 deletions

View File

@ -6,7 +6,6 @@ import (
"github.com/stretchr/testify/assert"
"dev.sum7.eu/genofire/golang-lib/database"
"dev.sum7.eu/genofire/golang-lib/web"
"dev.sum7.eu/genofire/golang-lib/web/webtest"
)
@ -15,9 +14,8 @@ func TestAPILogin(t *testing.T) {
assert := assert.New(t)
s := webtest.New(assert)
assert.NotNil(s)
s.DatabaseMigration(func(db *database.Database) {
SetupMigration(db)
})
SetupMigration(s.DB)
s.DB.MigrateTestdata()
hErr := web.HTTPError{}
// invalid

View File

@ -6,7 +6,6 @@ import (
"github.com/stretchr/testify/assert"
"dev.sum7.eu/genofire/golang-lib/database"
"dev.sum7.eu/genofire/golang-lib/web"
"dev.sum7.eu/genofire/golang-lib/web/webtest"
)
@ -15,9 +14,8 @@ func TestAPIPassword(t *testing.T) {
assert := assert.New(t)
s := webtest.New(assert)
assert.NotNil(s)
s.DatabaseMigration(func(db *database.Database) {
SetupMigration(db)
})
SetupMigration(s.DB)
s.DB.MigrateTestdata()
passwordCurrent := "CHANGEME"
passwordNew := "test"

View File

@ -6,7 +6,6 @@ import (
"github.com/stretchr/testify/assert"
"dev.sum7.eu/genofire/golang-lib/database"
"dev.sum7.eu/genofire/golang-lib/web"
"dev.sum7.eu/genofire/golang-lib/web/webtest"
)
@ -15,9 +14,8 @@ func TestAPIStatus(t *testing.T) {
assert := assert.New(t)
s := webtest.New(assert)
assert.NotNil(s)
s.DatabaseMigration(func(db *database.Database) {
SetupMigration(db)
})
SetupMigration(s.DB)
s.DB.MigrateTestdata()
hErr := web.HTTPError{}
// invalid

View File

@ -22,7 +22,7 @@ var (
)
type testServer struct {
db *database.Database
DB *database.Database
gin *gin.Engine
ws *web.Service
assert *assert.Assertions
@ -65,7 +65,7 @@ func New(assert *assert.Assertions) *testServer {
ws.LoadSession(r)
ws.Bind(r)
return &testServer{
db: &dbConfig,
DB: &dbConfig,
gin: r,
ws: ws,
assert: assert,
@ -75,13 +75,7 @@ func New(assert *assert.Assertions) *testServer {
// DatabaseForget, to run a test without a database
func (s *testServer) DatabaseForget() {
s.ws.DB = nil
s.db = nil
}
// DatabaseMigration set up a migration on webtest WebService
func (s *testServer) DatabaseMigration(f func(db *database.Database)) {
f(s.db)
s.db.MigrateTestdata()
s.DB = nil
}
// Request sends a request to webtest WebService