Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
Signed-off-by: Austin Abro <[email protected]>
  • Loading branch information
AustinAbro321 committed Sep 18, 2024
1 parent b0ba0e5 commit b0f79ba
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/internal/bigbang/bigbang.go
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ func createBBManifests(ctx context.Context, airgap bool, manifestDir string, val
Namespace: bb,
}

localGitRepoPath := filepath.Join(manifestDir, "gitrepository.yaml")
localGitRepoPath := filepath.Join(manifestDir, "bb-gitrepository.yaml")
if err := getBBFile(ctx, "gitrepository.yaml", localGitRepoPath, repo, version); err != nil {
return v1alpha1.ZarfManifest{}, err
}
Expand All @@ -483,7 +483,7 @@ func createBBManifests(ctx context.Context, airgap bool, manifestDir string, val
}}
}

localHelmReleasePath := filepath.Join(manifestDir, "helmrelease.yaml")
localHelmReleasePath := filepath.Join(manifestDir, "bb-helmrelease.yaml")
if err := getBBFile(ctx, "helmrelease.yaml", localHelmReleasePath, repo, version); err != nil {
return v1alpha1.ZarfManifest{}, err
}
Expand Down
72 changes: 68 additions & 4 deletions src/internal/bigbang/bigbang_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,9 @@ func TestAddBigBangManifests(t *testing.T) {
version: "2.35.0",
repo: "https://repo1.dso.mil/big-bang/bigbang",
expectedFiles: []string{
filepath.Join("testdata", "addBBManifests", "airgap-true", "gitrepository.yaml"),
filepath.Join("testdata", "addBBManifests", "airgap-true", "bb-gitrepository.yaml"),
filepath.Join("testdata", "addBBManifests", "airgap-true", "bb-zarf-credentials.yaml"),
filepath.Join("testdata", "addBBManifests", "airgap-true", "helmrelease.yaml"),
filepath.Join("testdata", "addBBManifests", "airgap-true", "bb-helmrelease.yaml"),
},
},
{
Expand All @@ -185,8 +185,8 @@ func TestAddBigBangManifests(t *testing.T) {
version: "2.0.0",
repo: "https://repo1.dso.mil/big-bang/bigbang",
expectedFiles: []string{
filepath.Join("testdata", "addBBManifests", "airgap-false", "gitrepository.yaml"),
filepath.Join("testdata", "addBBManifests", "airgap-false", "helmrelease.yaml"),
filepath.Join("testdata", "addBBManifests", "airgap-false", "bb-gitrepository.yaml"),
filepath.Join("testdata", "addBBManifests", "airgap-false", "bb-helmrelease.yaml"),
},
},
}
Expand Down Expand Up @@ -216,3 +216,67 @@ func TestAddBigBangManifests(t *testing.T) {
})
}
}

// func TestCreate(t *testing.T) {
// t.Parallel()
// tests := []struct {
// name string
// airgap bool
// valuesFiles []string
// version string
// repo string
// expectedFiles []string
// }{
// {
// name: "default BB install",
// airgap: true,
// valuesFiles: []string{},
// version: "2.35.0",
// repo: "https://repo1.dso.mil/big-bang/bigbang",
// expectedFiles: []string{
// filepath.Join("testdata", "create", "bb-gitrepository.yaml"),
// filepath.Join("testdata", "create", "bb-zarf-credentials.yaml"),
// filepath.Join("testdata", "create", "bb-helmrelease.yaml"),
// filepath.Join("testdata", "create", "zarf.yaml"),
// },
// },
// {
// name: "Airgap false with values files and v2beta1 version",
// airgap: false,
// valuesFiles: []string{
// filepath.Join("testdata", "addBBManifests", "airgap-false", "neuvector.yaml"),
// },
// version: "2.0.0",
// repo: "https://repo1.dso.mil/big-bang/bigbang",
// expectedFiles: []string{
// filepath.Join("testdata", "addBBManifests", "airgap-false", "gitrepository.yaml"),
// filepath.Join("testdata", "addBBManifests", "airgap-false", "helmrelease.yaml"),
// },
// },
// }

// for _, tt := range tests {
// t.Run(tt.name, func(t *testing.T) {
// t.Parallel()
// tempDir := t.TempDir()
// var expectedManifests []string
// for _, f := range tt.expectedFiles {
// expectedManifests = append(expectedManifests, filepath.Join(tempDir, filepath.Base(f)))
// }
// expectedManifests = append(expectedManifests, tt.valuesFiles...)
// manifest, err := createBBManifests(context.Background(), tt.airgap, tempDir, tt.valuesFiles, tt.version, tt.repo)
// require.NoError(t, err)
// require.ElementsMatch(t, expectedManifests, manifest.Files)

// for _, expectedFile := range tt.expectedFiles {
// _, filename := filepath.Split(expectedFile)
// generatedFile := filepath.Join(tempDir, filename)
// expectedContent, err := os.ReadFile(expectedFile)
// require.NoError(t, err)
// generatedContent, err := os.ReadFile(generatedFile)
// require.NoError(t, err)
// require.Equal(t, string(expectedContent), string(generatedContent))
// }
// })
// }
// }

0 comments on commit b0f79ba

Please sign in to comment.