forked from denisenkom/go-mssqldb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tds_go18_test.go
39 lines (36 loc) · 935 Bytes
/
tds_go18_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
package mssql
import (
"database/sql"
"fmt"
"net/url"
"os"
"testing"
)
func TestBadConnect(t *testing.T) {
t.Skip("still fails https://ci.appveyor.com/project/denisenkom/go-mssqldb/build/job/4jm8fmo1rywje9f9")
var badDSNs []string
if parsed, err := url.Parse(os.Getenv("SQLSERVER_DSN")); err == nil {
parsed.User = url.UserPassword("baduser", "badpwd")
badDSNs = append(badDSNs, parsed.String())
}
if len(os.Getenv("HOST")) > 0 && len(os.Getenv("INSTANCE")) > 0 {
badDSNs = append(badDSNs,
fmt.Sprintf(
"Server=%s\\%s;User ID=baduser;Password=badpwd",
os.Getenv("HOST"), os.Getenv("INSTANCE"),
),
)
}
SetLogger(testLogger{t})
for _, badDsn := range badDSNs {
conn, err := sql.Open("mssql", badDsn)
if err != nil {
t.Error("Open connection failed:", err.Error())
}
defer conn.Close()
err = conn.Ping()
if err == nil {
t.Error("Ping should fail for connection: ", badDsn)
}
}
}