-
Notifications
You must be signed in to change notification settings - Fork 4
/
main_test.go
58 lines (41 loc) · 942 Bytes
/
main_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package main
import (
"fmt"
"log"
"os"
"testing"
"gitlab.com/voip-services/go-kamailio-api/api/controllers"
"github.com/golang-migrate/migrate"
_ "github.com/golang-migrate/migrate/database/postgres"
_ "github.com/golang-migrate/migrate/source/file"
)
var app controllers.App
func TestMain(m *testing.M) {
dbURL := fmt.Sprintf("%s?sslmode=disable", os.Getenv("KAM_DB_URL"))
//log.Printf("db %s", dbUrl)
app.Initialize(dbURL)
app.NewClient("go-kamailio-api_devcontainer_mmock_1:8082") // init mmock
mgr, err := migrate.New(
"file://migrates",
dbURL)
if err != nil {
log.Fatal(err)
}
migrateUp(mgr)
code := m.Run()
migrateDown(mgr)
os.Exit(code)
}
func migrateUp(mgr *migrate.Migrate) {
// migration up
if err := mgr.Up(); err != nil {
log.Println(err)
}
}
func migrateDown(mgr *migrate.Migrate) {
// migrations down
if err := mgr.Down(); err != nil {
log.Println(err)
}
}
// TODO: http test