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

test: move lint e2e test to unit test #3334

Merged
merged 10 commits into from
Dec 16, 2024
Prev Previous commit
Next Next commit
shorten test to focus on what we're testing
Signed-off-by: Austin Abro <AustinAbro321@gmail.com>
  • Loading branch information
AustinAbro321 committed Dec 16, 2024
commit bac67fa125a83529e29103346d4ec28c213442d9
57 changes: 9 additions & 48 deletions src/pkg/lint/lint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ func TestLintPackageWithImports(t *testing.T) {
}
ctx := context.Background()
findings := []PackageFinding{
// unset exists in both the root and imported package
{
YqPath: "",
Description: "package template UNSET is not set and won't be evaluated during lint",
Expand All @@ -111,68 +112,28 @@ func TestLintPackageWithImports(t *testing.T) {
PackagePathOverride: "linted-import",
Severity: SevWarn,
},
{
YqPath: ".components.[0].images.[0]",
Description: "Image not pinned with digest",
Item: "ghcr.io/zarf-dev/doom-game:0.0.1",
PackageNameOverride: "dos-games",
PackagePathOverride: "oci://ghcr.io/zarf-dev/packages/dos-games:1.1.0",
Severity: SevWarn,
},
{
YqPath: ".components.[1].images.[0]",
Description: "Image not pinned with digest",
Item: "registry.com:9001/whatever/image:latest",
PackageNameOverride: "linted-import",
PackagePathOverride: "linted-import",
Severity: SevWarn,
},
{
YqPath: ".components.[1].images.[2]",
Description: "Image not pinned with digest",
Item: "busybox:latest",
PackageNameOverride: "linted-import",
PackagePathOverride: "linted-import",
Severity: SevWarn,
},
{
YqPath: "",
Description: "package template UBUNTU_IMAGE is not set and won't be evaluated during lint",
Description: "package template UNSET is not set and won't be evaluated during lint",
Item: "",
PackageNameOverride: "lint",
PackagePathOverride: ".",
Severity: SevWarn,
},
{
YqPath: ".components.[1].repos.[0]",
Description: "Unpinned repository",
Item: "https://github.com/zarf-dev/zarf-public-test.git",
PackageNameOverride: "lint",
PackagePathOverride: ".",
Severity: SevWarn,
},
{
YqPath: ".components.[1].repos.[2]",
Description: "Unpinned repository",
Item: "https://gitlab.com/gitlab-org/build/omnibus-mirror/pcre2/-/tree/vreverse?ref_type=heads",
PackageNameOverride: "lint",
PackagePathOverride: ".",
Severity: SevWarn,
},
{
YqPath: ".components.[1].images.[0]",
YqPath: ".components.[0].images.[0]",
Description: "Image not pinned with digest",
Item: "registry.com:9001/whatever/image:1.0.0",
PackageNameOverride: "lint",
PackagePathOverride: ".",
Item: "ghcr.io/zarf-dev/doom-game:0.0.1",
PackageNameOverride: "dos-games",
PackagePathOverride: "oci://ghcr.io/zarf-dev/packages/dos-games:1.1.0",
Severity: SevWarn,
},
{
YqPath: ".components.[1].images.[2]",
YqPath: ".components.[1].images.[0]",
Description: "Image not pinned with digest",
Item: "busybox:latest",
PackageNameOverride: "lint",
PackagePathOverride: ".",
PackageNameOverride: "linted-import",
PackagePathOverride: "linted-import",
Severity: SevWarn,
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ variables:

components:
- name: dont-care
images:
- image-that-should-not-show-up-in-lint:unpinned

- name: import-test
images:
- registry.com:9001/whatever/image:latest
- busybox@sha256:3fbc632167424a6d997e74f52b878d7cc478225cffac6bc977eedfe51c7f4e79
- busybox:###ZARF_PKG_TMPL_BUSYBOX_IMAGE###
- busybox@sha256:3fbc632167424a6d997e74f52b878d7cc478225cffac6bc977eedfe51c7f4e79
- busybox:###ZARF_PKG_TMPL_UNSET###

- name: oci-games-url
Expand Down
14 changes: 1 addition & 13 deletions src/pkg/lint/testdata/lint-with-imports/zarf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,9 @@ components:
path: linted-import

- name: full-repo
repos:
- https://github.com/zarf-dev/zarf-public-test.git
- https://dev.azure.com/defenseunicorns/zarf-public-test/_git/zarf-public-test@v0.0.1
- https://gitlab.com/gitlab-org/build/omnibus-mirror/pcre2/-/tree/vreverse?ref_type=heads
images:
- registry.com:9001/whatever/image:1.0.0
- busybox@sha256:3fbc632167424a6d997e74f52b878d7cc478225cffac6bc977eedfe51c7f4e79
- busybox:###ZARF_PKG_TMPL_BUSYBOX_IMAGE###
- ubuntu:###ZARF_PKG_TMPL_UBUNTU_IMAGE###
files:
- source: https://github.com/k3s-io/k3s/releases/download/v1.28.2+k3s1/k3s
shasum: 2f041d37a2c6d54d53e106e1c7713bc48f806f3919b0d9e092f5fcbdc55b41cf
target: src/
- source: file-without-shasum.txt
target: src/
- busybox:###ZARF_PKG_TMPL_UNSET###

- name: oci-games-url
import:
Expand Down