Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix compare tool generation and add better testing #1242

Merged
merged 2 commits into from
Jan 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/internal/packager/sbom/catalog.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ func Catalog(componentSBOMs map[string]*types.ComponentSBOM, tagToImage map[name
currImage++
}

if len(componentSBOMs) > 0 && len(tagToImage) > 0 {
// Include the compare tool if there are any image SBOMs OR component SBOMs
if len(componentSBOMs) > 0 || len(tagToImage) > 0 {
Racer159 marked this conversation as resolved.
Show resolved Hide resolved
if err := builder.createSBOMCompareAsset(); err != nil {
builder.spinner.Fatalf(err, "Unable to create SBOM compare tool")
}
Expand Down
6 changes: 6 additions & 0 deletions src/test/e2e/06_create_sbom_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ func TestCreateSBOM(t *testing.T) {
// Test that the game package generates the SBOMs we expect (images only)
_, err = os.ReadFile(filepath.Join(sbomPath, "dos-games", "sbom-viewer-defenseunicorns_zarf-game_multi-tile-dark.html"))
require.NoError(t, err)
_, err = os.ReadFile(filepath.Join(sbomPath, "dos-games", "compare.html"))
require.NoError(t, err)
_, err = os.ReadFile(filepath.Join(sbomPath, "dos-games", "defenseunicorns_zarf-game_multi-tile-dark.json"))
require.NoError(t, err)

Expand All @@ -39,6 +41,8 @@ func TestCreateSBOM(t *testing.T) {
// Test that the game package generates the SBOMs we expect (images only)
_, err = os.ReadFile(filepath.Join(sbomPath, "dos-games", "sbom-viewer-defenseunicorns_zarf-game_multi-tile-dark.html"))
require.NoError(t, err)
_, err = os.ReadFile(filepath.Join(sbomPath, "dos-games", "compare.html"))
require.NoError(t, err)
_, err = os.ReadFile(filepath.Join(sbomPath, "dos-games", "defenseunicorns_zarf-game_multi-tile-dark.json"))
require.NoError(t, err)

Expand All @@ -62,6 +66,8 @@ func TestCreateSBOM(t *testing.T) {
require.NoError(t, err)
_, err = os.ReadFile(filepath.Join(sbomPath, "init", "zarf-component-k3s.json"))
require.NoError(t, err)
_, err = os.ReadFile(filepath.Join(sbomPath, "init", "compare.html"))
require.NoError(t, err)

e2e.cleanFiles(cachePath, sbomPath, pkgName)
}