TestGitOpsCheckDeclarative tests CheckRelease with declarative (SDL) files using PostgreSQL.
(t *testing.T)
| 1380 | |
| 1381 | // TestGitOpsCheckDeclarative tests CheckRelease with declarative (SDL) files using PostgreSQL. |
| 1382 | func TestGitOpsCheckDeclarative(t *testing.T) { |
| 1383 | t.Parallel() |
| 1384 | a := require.New(t) |
| 1385 | ctx := context.Background() |
| 1386 | ctl := &controller{} |
| 1387 | ctx, err := ctl.StartServerWithExternalPg(ctx) |
| 1388 | a.NoError(err) |
| 1389 | defer ctl.Close(ctx) |
| 1390 | |
| 1391 | // Create a project. |
| 1392 | projectID := generateRandomString("gitops-decl") |
| 1393 | projectResp, err := ctl.projectServiceClient.CreateProject(ctx, connect.NewRequest(&v1pb.CreateProjectRequest{ |
| 1394 | Project: &v1pb.Project{ |
| 1395 | Name: fmt.Sprintf("projects/%s", projectID), |
| 1396 | Title: projectID, |
| 1397 | AllowSelfApproval: true, |
| 1398 | }, |
| 1399 | ProjectId: projectID, |
| 1400 | })) |
| 1401 | a.NoError(err) |
| 1402 | project := projectResp.Msg |
| 1403 | |
| 1404 | // Provision PostgreSQL instance. |
| 1405 | pgContainer, err := getPgContainer(ctx) |
| 1406 | a.NoError(err) |
| 1407 | defer pgContainer.Close(ctx) |
| 1408 | |
| 1409 | pgInstanceResp, err := ctl.instanceServiceClient.CreateInstance(ctx, connect.NewRequest(&v1pb.CreateInstanceRequest{ |
| 1410 | InstanceId: generateRandomString("instance"), |
| 1411 | Instance: &v1pb.Instance{ |
| 1412 | Title: "gitops-decl-pg", |
| 1413 | Engine: v1pb.Engine_POSTGRES, |
| 1414 | Environment: new("environments/test"), |
| 1415 | Activation: true, |
| 1416 | DataSources: []*v1pb.DataSource{{ |
| 1417 | Type: v1pb.DataSourceType_ADMIN, |
| 1418 | Host: pgContainer.host, |
| 1419 | Port: pgContainer.port, |
| 1420 | Username: "postgres", |
| 1421 | Password: "root-password", |
| 1422 | Id: "admin", |
| 1423 | }}, |
| 1424 | }, |
| 1425 | })) |
| 1426 | a.NoError(err) |
| 1427 | pgInstance := pgInstanceResp.Msg |
| 1428 | |
| 1429 | // Create database. |
| 1430 | databaseName := "gitops_decl_db" |
| 1431 | err = ctl.createDatabase(ctx, project, pgInstance, nil, databaseName, "postgres") |
| 1432 | a.NoError(err) |
| 1433 | |
| 1434 | // Create a release with declarative SDL files. |
| 1435 | release := &v1pb.Release{ |
| 1436 | Type: v1pb.Release_DECLARATIVE, |
| 1437 | Files: []*v1pb.Release_File{ |
| 1438 | { |
| 1439 | Path: "schema/users.sql", |
nothing calls this directly
no test coverage detected