(t *testing.T)
| 265 | } |
| 266 | |
| 267 | func TestSQLAdminExecuteStopOnError(t *testing.T) { |
| 268 | tests := []struct { |
| 269 | name string |
| 270 | databaseName string |
| 271 | dbType storepb.Engine |
| 272 | prepareStatements string |
| 273 | query string |
| 274 | wantResults int |
| 275 | wantError bool |
| 276 | }{ |
| 277 | { |
| 278 | name: "MySQL AdminExecute - Second statement fails", |
| 279 | databaseName: "TestAdminStopOnError1", |
| 280 | dbType: storepb.Engine_MYSQL, |
| 281 | prepareStatements: "CREATE TABLE admin_tbl1(id INT PRIMARY KEY, name VARCHAR(64));", |
| 282 | query: "INSERT INTO admin_tbl1 VALUES(1, 'Alice'); INSERT INTO nonexistent VALUES(2, 'Bob'); INSERT INTO admin_tbl1 VALUES(3, 'Charlie');", |
| 283 | wantResults: 1, |
| 284 | wantError: true, |
| 285 | }, |
| 286 | { |
| 287 | name: "PostgreSQL AdminExecute - Second statement fails", |
| 288 | databaseName: "TestAdminStopOnError2", |
| 289 | dbType: storepb.Engine_POSTGRES, |
| 290 | prepareStatements: "CREATE TABLE admin_tbl2(id INT PRIMARY KEY, name VARCHAR(64));", |
| 291 | query: "INSERT INTO admin_tbl2 VALUES(1, 'Alice'); INSERT INTO nonexistent VALUES(2, 'Bob'); INSERT INTO admin_tbl2 VALUES(3, 'Charlie');", |
| 292 | wantResults: 1, |
| 293 | wantError: true, |
| 294 | }, |
| 295 | } |
| 296 | |
| 297 | t.Parallel() |
| 298 | a := require.New(t) |
| 299 | ctx := context.Background() |
| 300 | ctl := &controller{} |
| 301 | ctx, err := ctl.StartServerWithExternalPg(ctx) |
| 302 | a.NoError(err) |
| 303 | t.Cleanup(func() { |
| 304 | ctl.Close(ctx) |
| 305 | }) |
| 306 | |
| 307 | mysqlContainer, err := getMySQLContainer(ctx) |
| 308 | t.Cleanup(func() { |
| 309 | mysqlContainer.Close(ctx) |
| 310 | }) |
| 311 | a.NoError(err) |
| 312 | |
| 313 | pgContainer, err := getPgContainer(ctx) |
| 314 | t.Cleanup(func() { |
| 315 | pgContainer.Close(ctx) |
| 316 | }) |
| 317 | a.NoError(err) |
| 318 | |
| 319 | mysqlInstanceResp, err := ctl.instanceServiceClient.CreateInstance(ctx, connect.NewRequest(&v1pb.CreateInstanceRequest{ |
| 320 | InstanceId: generateRandomString("instance"), |
| 321 | Instance: &v1pb.Instance{ |
| 322 | Title: "mysqlInstance", |
| 323 | Engine: v1pb.Engine_MYSQL, |
| 324 | Environment: new("environments/prod"), |
nothing calls this directly
no test coverage detected