[wip] add run tests
This commit is contained in:
parent
c83aab5f94
commit
0b598ef0b2
2 changed files with 17 additions and 9 deletions
|
|
@ -20,8 +20,8 @@ steps:
|
|||
"Wait databases":
|
||||
image: gitnet.fr/deblan/timeout:latest
|
||||
commands:
|
||||
- /bin/timeout -t 30 -v -c 'while true; do nc -z -v db 3306 2>&1 | grep succeeded && exit 0; sleep 0.5; done'
|
||||
- /bin/timeout -t 30 -v -c 'while true; do nc -z -v db 5432 2>&1 | grep succeeded && exit 0; sleep 0.5; done'
|
||||
- /bin/timeout -t 30 -v -c 'while true; do nc -z -v service-mysql 3306 2>&1 | grep succeeded && exit 0; sleep 0.5; done'
|
||||
- /bin/timeout -t 30 -v -c 'while true; do nc -z -v service-postgres 5432 2>&1 | grep succeeded && exit 0; sleep 0.5; done'
|
||||
|
||||
"Fill MySQL":
|
||||
image: *mysql_image
|
||||
|
|
@ -39,6 +39,7 @@ services:
|
|||
ports: ['5432']
|
||||
environment:
|
||||
- POSTGRES_USER=postgres
|
||||
- POSTGRES_DB=test
|
||||
- POSTGRES_HOST_AUTH_METHOD=trust
|
||||
|
||||
service-mysql:
|
||||
|
|
|
|||
|
|
@ -49,14 +49,21 @@ func TestAppRun(t *testing.T) {
|
|||
db, _ := sql.Open(databaseConfig.Type, databaseConfig.Dsn)
|
||||
schema, _ := config.LoadSchemaConfigFromFile("../tests/schema.yml")
|
||||
|
||||
app := App{}
|
||||
app.Run(db, schema, faker.NewFakeManager(), databaseConfig)
|
||||
dsns := []string{
|
||||
"mysql://tcp(service-mysql)/test",
|
||||
// "postgres://postgres@tcp(service-postgres)/test",
|
||||
}
|
||||
|
||||
var count int
|
||||
row := db.QueryRow("SELECT COUNT(*) FROM `table_truncate1`")
|
||||
row.Scan(&count)
|
||||
for dns := range dsns {
|
||||
app := App{}
|
||||
app.Run(db, schema, faker.NewFakeManager(), databaseConfig)
|
||||
|
||||
if count != 0 {
|
||||
t.Fatalf("TestAppRuny: table_truncate1 check failed")
|
||||
var count int
|
||||
row := db.QueryRow("SELECT COUNT(*) FROM table_truncate1")
|
||||
row.Scan(&count)
|
||||
|
||||
if count != 0 {
|
||||
t.Fatalf("TestAppRuny: table_truncate1 check failed")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue