MCPcopy Index your code
hub / github.com/bytebase/bytebase / TestGitOpsCheckDeclarativeMultipleFiles

Function TestGitOpsCheckDeclarativeMultipleFiles

backend/tests/gitops_test.go:1803–1899  ·  view source on GitHub ↗

TestGitOpsCheckDeclarativeMultipleFiles tests CheckRelease with multiple declarative SDL files.

(t *testing.T)

Source from the content-addressed store, hash-verified

1801
1802// TestGitOpsCheckDeclarativeMultipleFiles tests CheckRelease with multiple declarative SDL files.
1803func TestGitOpsCheckDeclarativeMultipleFiles(t *testing.T) {
1804 t.Parallel()
1805 a := require.New(t)
1806 ctx := context.Background()
1807 ctl := &controller{}
1808 ctx, err := ctl.StartServerWithExternalPg(ctx)
1809 a.NoError(err)
1810 defer ctl.Close(ctx)
1811
1812 // Create a project.
1813 projectID := generateRandomString("gitops-multi-decl")
1814 projectResp, err := ctl.projectServiceClient.CreateProject(ctx, connect.NewRequest(&v1pb.CreateProjectRequest{
1815 Project: &v1pb.Project{
1816 Name: fmt.Sprintf("projects/%s", projectID),
1817 Title: projectID,
1818 AllowSelfApproval: true,
1819 },
1820 ProjectId: projectID,
1821 }))
1822 a.NoError(err)
1823 project := projectResp.Msg
1824
1825 // Provision PostgreSQL instance.
1826 pgContainer, err := getPgContainer(ctx)
1827 a.NoError(err)
1828 defer pgContainer.Close(ctx)
1829
1830 pgInstanceResp, err := ctl.instanceServiceClient.CreateInstance(ctx, connect.NewRequest(&v1pb.CreateInstanceRequest{
1831 InstanceId: generateRandomString("instance"),
1832 Instance: &v1pb.Instance{
1833 Title: "gitops-multi-decl-pg",
1834 Engine: v1pb.Engine_POSTGRES,
1835 Environment: new("environments/test"),
1836 Activation: true,
1837 DataSources: []*v1pb.DataSource{{
1838 Type: v1pb.DataSourceType_ADMIN,
1839 Host: pgContainer.host,
1840 Port: pgContainer.port,
1841 Username: "postgres",
1842 Password: "root-password",
1843 Id: "admin",
1844 }},
1845 },
1846 }))
1847 a.NoError(err)
1848 pgInstance := pgInstanceResp.Msg
1849
1850 // Create database.
1851 databaseName := "gitops_multi_decl_db"
1852 err = ctl.createDatabase(ctx, project, pgInstance, nil, databaseName, "postgres")
1853 a.NoError(err)
1854
1855 // Create a release with multiple declarative SDL files.
1856 release := &v1pb.Release{
1857 Type: v1pb.Release_DECLARATIVE,
1858 Files: []*v1pb.Release_File{
1859 {
1860 Path: "schema/users.sql",

Callers

nothing calls this directly

Calls 9

CloseMethod · 0.95
createDatabaseMethod · 0.95
generateRandomStringFunction · 0.85
getPgContainerFunction · 0.85
CreateProjectMethod · 0.65
CloseMethod · 0.65
CreateInstanceMethod · 0.65
CheckReleaseMethod · 0.65

Tested by

no test coverage detected