-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain_test.go
More file actions
45 lines (37 loc) · 709 Bytes
/
main_test.go
File metadata and controls
45 lines (37 loc) · 709 Bytes
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
// Copyright 2023 Bill Nixon. All rights reserved.
// Use of this source code is governed by the license found in the LICENSE file.
package main
import (
"database/sql"
"os"
"testing"
)
const (
driverName = "mysql"
dataSourceName = "gobid_test:password@/gobid_test?parseTime=true&multiStatements=true"
file = "sql/test.sql"
)
func setup() {
db, err := sql.Open(driverName, dataSourceName)
if err != nil {
panic(err)
}
script, err := os.ReadFile(file)
if err != nil {
panic(err)
}
_, err = db.Exec(string(script))
if err != nil {
panic(err)
}
}
func teardown() {
}
func TestMain(m *testing.M) {
setup()
ret := m.Run()
if ret == 0 {
teardown()
}
os.Exit(ret)
}