MCPcopy
hub / github.com/golang-migrate/migrate / testMultiStatement

Function testMultiStatement

database/sqlserver/sqlserver_test.go:160–192  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

158}
159
160func testMultiStatement(t *testing.T) {
161 dktesting.ParallelTest(t, specs, func(t *testing.T, c dktest.ContainerInfo) {
162 SkipIfUnsupportedArch(t, c)
163 ip, port, err := c.Port(defaultPort)
164 if err != nil {
165 t.Fatal(err)
166 }
167
168 addr := msConnectionString(ip, port)
169 ms := &SQLServer{}
170 d, err := ms.Open(addr)
171 if err != nil {
172 t.Fatal(err)
173 }
174 defer func() {
175 if err := d.Close(); err != nil {
176 t.Error(err)
177 }
178 }()
179 if err := d.Run(strings.NewReader("CREATE TABLE foo (foo text); CREATE TABLE bar (bar text);")); err != nil {
180 t.Fatalf("expected err to be nil, got %v", err)
181 }
182
183 // make sure second table exists
184 var exists int
185 if err := d.(*SQLServer).conn.QueryRowContext(context.Background(), "SELECT COUNT(1) FROM information_schema.tables WHERE table_name = 'bar' AND table_schema = (SELECT schema_name()) AND table_catalog = (SELECT db_name())").Scan(&exists); err != nil {
186 t.Fatal(err)
187 }
188 if exists != 1 {
189 t.Fatalf("expected table bar to exist")
190 }
191 })
192}
193
194func testErrorParsing(t *testing.T) {
195 dktesting.ParallelTest(t, specs, func(t *testing.T, c dktest.ContainerInfo) {

Callers

nothing calls this directly

Calls 8

OpenMethod · 0.95
ParallelTestFunction · 0.92
SkipIfUnsupportedArchFunction · 0.85
msConnectionStringFunction · 0.85
PortMethod · 0.65
CloseMethod · 0.65
RunMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…