-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain_test.go
57 lines (47 loc) · 1005 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
package main
import (
"log"
"os"
"os/exec"
"testing"
"time"
app "github.com/Golang-Gang/Go-Rewrite/goServer"
setup "github.com/Golang-Gang/Go-Rewrite/goServer/setup"
"github.com/joho/godotenv"
)
var a app.App
func TestMain(m *testing.M) {
/*
godotenv.Load(".env")
a.Initialize(
os.Getenv("APP_DB_USERNAME"),
os.Getenv("APP_DB_PASSWORD"),
os.Getenv("APP_DB_NAME"))
app.SetupTables(a.DB)
code := m.Run()
os.Exit(code)
*/
godotenv.Load(".env")
a := app.App{}
a.Initialize(
os.Getenv("APP_DB_USERNAME"),
os.Getenv("APP_DB_PASSWORD"),
os.Getenv("APP_DB_NAME"),
os.Getenv("APP_DB_HOST"))
setup.SetupTables(a.DB)
port := os.Getenv("PORT")
if port == "" {
port = "8080"
}
go a.Run(port)
time.Sleep(5 * time.Second)
cmd := exec.Command("npm", "test")
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
err := cmd.Run()
if err != nil {
log.Fatalf("cmd.Run() failed with %s\n", err)
os.Exit(1)
}
os.Exit(0)
}