-
-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Christian Kotzbauer <[email protected]>
- Loading branch information
1 parent
77f060d
commit 240360b
Showing
3 changed files
with
62 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package target | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
type testData struct { | ||
input string | ||
expected string | ||
g *GitTarget | ||
} | ||
|
||
func TestImageIDToFilePath(t *testing.T) { | ||
tests := []testData{ | ||
{ | ||
input: "alpine:latest", | ||
expected: "alpine_latest/sbom.json", | ||
g: NewGitTarget("", "", "", "", "", "", "", ""), | ||
}, | ||
{ | ||
input: "alpine@sha256:21a3deaa0d32a8057914f36584b5288d2e5ecc984380bc0118285c70fa8c9300", | ||
expected: "alpine/sha256_21a3deaa0d32a8057914f36584b5288d2e5ecc984380bc0118285c70fa8c9300/sbom.json", | ||
g: NewGitTarget("", "", "", "", "", "", "", ""), | ||
}, | ||
{ | ||
input: "", | ||
expected: "sbom.json", | ||
g: NewGitTarget("", "", "", "", "", "", "", ""), | ||
}, | ||
{ | ||
input: "alpine:latest", | ||
expected: "/git/dev/alpine_latest/sbom.spdx", | ||
g: NewGitTarget("/git", "dev", "", "", "", "", "", "spdx"), | ||
}, | ||
{ | ||
input: "alpine@sha256:21a3deaa0d32a8057914f36584b5288d2e5ecc984380bc0118285c70fa8c9300", | ||
expected: "/git/sbom/prod/cluster1/alpine/sha256_21a3deaa0d32a8057914f36584b5288d2e5ecc984380bc0118285c70fa8c9300/sbom.spdx", | ||
g: NewGitTarget("/git/sbom", "prod/cluster1", "", "", "", "", "", "spdx"), | ||
}, | ||
{ | ||
input: "", | ||
expected: "/git/sbom.json", | ||
g: NewGitTarget("/git", "", "", "", "", "", "", ""), | ||
}, | ||
} | ||
|
||
for _, v := range tests { | ||
t.Run("", func(t *testing.T) { | ||
out := v.g.ImageIDToFilePath(v.input) | ||
assert.Equal(t, v.expected, out) | ||
}) | ||
} | ||
} |