(t *testing.T)
| 21 | ) |
| 22 | |
| 23 | func TestGitOpsCheck(t *testing.T) { |
| 24 | t.Parallel() |
| 25 | a := require.New(t) |
| 26 | ctx := context.Background() |
| 27 | ctl := &controller{} |
| 28 | ctx, err := ctl.StartServerWithExternalPg(ctx) |
| 29 | a.NoError(err) |
| 30 | defer ctl.Close(ctx) |
| 31 | |
| 32 | // Create a project for GitOps testing. |
| 33 | projectID := generateRandomString("gitops-check") |
| 34 | projectResp, err := ctl.projectServiceClient.CreateProject(ctx, connect.NewRequest(&v1pb.CreateProjectRequest{ |
| 35 | Project: &v1pb.Project{ |
| 36 | Name: fmt.Sprintf("projects/%s", projectID), |
| 37 | Title: projectID, |
| 38 | AllowSelfApproval: true, |
| 39 | }, |
| 40 | ProjectId: projectID, |
| 41 | })) |
| 42 | a.NoError(err) |
| 43 | project := projectResp.Msg |
| 44 | |
| 45 | // Provision test and prod instances. |
| 46 | instanceRootDir := t.TempDir() |
| 47 | |
| 48 | testInstanceDir, err := ctl.provisionSQLiteInstance(instanceRootDir, "gitops-check-test") |
| 49 | a.NoError(err) |
| 50 | |
| 51 | prodInstanceDir, err := ctl.provisionSQLiteInstance(instanceRootDir, "gitops-check-prod") |
| 52 | a.NoError(err) |
| 53 | |
| 54 | // Add the provisioned instances. |
| 55 | testInstanceResp, err := ctl.instanceServiceClient.CreateInstance(ctx, connect.NewRequest(&v1pb.CreateInstanceRequest{ |
| 56 | InstanceId: generateRandomString("instance"), |
| 57 | Instance: &v1pb.Instance{ |
| 58 | Title: "gitops-check-test", |
| 59 | Engine: v1pb.Engine_SQLITE, |
| 60 | Environment: new("environments/test"), |
| 61 | Activation: true, |
| 62 | DataSources: []*v1pb.DataSource{{Type: v1pb.DataSourceType_ADMIN, Host: testInstanceDir, Id: "admin"}}, |
| 63 | }, |
| 64 | })) |
| 65 | a.NoError(err) |
| 66 | testInstance := testInstanceResp.Msg |
| 67 | |
| 68 | prodInstanceResp, err := ctl.instanceServiceClient.CreateInstance(ctx, connect.NewRequest(&v1pb.CreateInstanceRequest{ |
| 69 | InstanceId: generateRandomString("instance"), |
| 70 | Instance: &v1pb.Instance{ |
| 71 | Title: "gitops-check-prod", |
| 72 | Engine: v1pb.Engine_SQLITE, |
| 73 | Environment: new("environments/prod"), |
| 74 | Activation: true, |
| 75 | DataSources: []*v1pb.DataSource{{Type: v1pb.DataSourceType_ADMIN, Host: prodInstanceDir, Id: "admin"}}, |
| 76 | }, |
| 77 | })) |
| 78 | a.NoError(err) |
| 79 | prodInstance := prodInstanceResp.Msg |
| 80 |
nothing calls this directly
no test coverage detected