-
Notifications
You must be signed in to change notification settings - Fork 0
/
mssql_test.go
59 lines (50 loc) · 1.3 KB
/
mssql_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
59
package mssql_test
import (
"context"
"database/sql"
"fmt"
"testing"
"time"
)
import (
_ "github.com/denisenkom/go-mssqldb"
"github.com/dhui/dktest"
)
import (
"github.com/dhui/satomic/savepointers/mssql"
"github.com/dhui/satomic/savepointers/savepointertest"
)
const (
password = "insecurePassword1"
timeout = 3 * time.Minute
)
var env = map[string]string{
// Developer edition (the default) is free
// License: https://go.microsoft.com/fwlink/?linkid=857698
"ACCEPT_EULA": "Y",
"SA_PASSWORD": password,
}
var msSQLDBGetter savepointertest.DBGetter = func(ctx context.Context, c dktest.ContainerInfo) (*sql.DB, error) {
ip, port, err := c.FirstPort()
if err != nil {
return nil, err
}
connStr := fmt.Sprintf("sqlserver://sa:%s@%s:%s", password, ip, port)
db, err := sql.Open("sqlserver", connStr)
if err != nil {
return nil, err
}
if err := db.PingContext(ctx); err != nil {
return nil, err
}
return db, nil
}
func TestSavepointerMSSQL(t *testing.T) {
t.Parallel()
versions := []string{
"mcr.microsoft.com/mssql/server:2017-latest",
"mcr.microsoft.com/mssql/server:2019-latest",
}
savepointertest.TestSavepointerWithDocker(t, mssql.Savepointer{}, versions, dktest.Options{Env: env,
PortRequired: true, ReadyFunc: msSQLDBGetter.ReadyFunc(), Timeout: timeout}, msSQLDBGetter)
}