-
Notifications
You must be signed in to change notification settings - Fork 22
/
schema_mssql_test.go
96 lines (84 loc) · 2.7 KB
/
schema_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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
package schema_test
import (
"fmt"
_ "github.com/denisenkom/go-mssqldb" // mssql
// _ "github.com/minus5/gofreetds" // mssql
. "github.com/onsi/ginkgo"
// . "github.com/onsi/gomega"
)
// Database/user setup script, run by Docker: docker-db-init-mssql.sql
var _ = Describe("schema", func() {
Context("using github.com/denisenkom/go-mssqldb (Microsoft SQL-Server)", func() {
const (
user = "test_user"
pass = "Password-123"
host = "localhost"
port = "41433"
)
var mssql = &testParams{
DriverName: "mssql",
ConnStr: fmt.Sprintf("user id=%s;password=%s;server=%s;port=%s", user, pass, host, port),
// ConnStr: fmt.Sprintf("user id=%s;password=%s;server=%s:%s", user, pass, host, port), // gofreetds
CreateDDL: []string{`
CREATE TABLE web_resource (
id INTEGER NOT NULL,
url NVARCHAR NOT NULL UNIQUE,
content VARBINARY,
compressed_size INTEGER NOT NULL,
content_length INTEGER NOT NULL,
content_type NVARCHAR NOT NULL,
etag NVARCHAR NOT NULL,
last_modified NVARCHAR NOT NULL,
created_at DATETIME NOT NULL,
modified_at DATETIME,
PRIMARY KEY (id)
)`,
`CREATE INDEX idx_web_resource_url ON web_resource(url)`,
`CREATE INDEX idx_web_resource_created_at ON web_resource (created_at)`,
`CREATE INDEX idx_web_resource_modified_at ON web_resource (modified_at)`,
`CREATE VIEW web_resource_view AS SELECT id, url FROM web_resource`, // TODO gofreetds barfs on this!?
// `CREATE VIEW web_resource_view AS SELECT t.id, t.url FROM web_resource t`,
// `CREATE VIEW web_resource_view AS (SELECT id, url FROM web_resource)`,
// `CREATE VIEW web_resource_view AS (SELECT t.id, t.url FROM web_resource t)`,
`CREATE TABLE person (
given_name NVARCHAR NOT NULL,
family_name NVARCHAR NOT NULL,
PRIMARY KEY (family_name, given_name)
)`,
},
DropDDL: []string{
`DROP TABLE person`,
`DROP VIEW IF EXISTS web_resource_view`,
`DROP INDEX IF EXISTS idx_web_resource_modified_at ON web_resource`,
`DROP INDEX IF EXISTS idx_web_resource_created_at ON web_resource`,
`DROP INDEX IF EXISTS idx_web_resource_url ON web_resource`,
`DROP TABLE web_resource`,
},
TableExpRes: []string{
"id",
"url",
"content",
"compressed_size",
"content_length",
"content_type",
"etag",
"last_modified",
"created_at",
"modified_at",
},
ViewExpRes: []string{
"id",
"url",
},
TableNamesExpRes: [][2]string{
{"test_db", "person"},
{"test_db", "web_resource"},
},
ViewNamesExpRes: [][2]string{
{"test_db", "web_resource_view"},
},
PrimaryKeysExpRes: []string{"family_name", "given_name"},
}
SchemaTestRunner(mssql)
})
})