From ee17f0e673bf01d26912ae3dd7ce9f401dd3363d Mon Sep 17 00:00:00 2001 From: bakito Date: Sun, 29 Oct 2023 02:12:53 +0200 Subject: [PATCH] add e2e test --- .github/workflows/e2e.yaml | 26 ++++++++++++++++++++++++++ pkg/export/export.go | 6 +++++- pkg/types/config_test.go | 7 ++++++- 3 files changed, 37 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/e2e.yaml diff --git a/.github/workflows/e2e.yaml b/.github/workflows/e2e.yaml new file mode 100644 index 0000000..21c32e6 --- /dev/null +++ b/.github/workflows/e2e.yaml @@ -0,0 +1,26 @@ +name: e2e tests + +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + e2e: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version-file: "go.mod" + + - name: Install kind with registry + uses: bakito/kind-with-registry-action@main + + - name: Run Exporter + run: go run . --config config.yaml diff --git a/pkg/export/export.go b/pkg/export/export.go index d7874e5..ba54358 100644 --- a/pkg/export/export.go +++ b/pkg/export/export.go @@ -140,13 +140,17 @@ func (e *exporter) writeIntro() { if e.config.Summary { e.l.Printf(" summary 📊\n") } + if e.config.ConsiderOwnerReferences { + e.l.Printf(" considering owner references 👑\n") + } + if e.config.AsLists { e.l.Printf(" as lists 📦\n") } else if e.config.QueryPageSize != 0 { e.l.Printf(" query page size %d 📃\n", e.config.QueryPageSize) } if e.config.Archive { - e.l.Printf(" compress as archive ️\n") + e.l.Printf(" compress as archive ️🗜\n") if e.config.ArchiveRetentionDays > 0 { e.l.Printf(" delete archives older than %d days 🚮\n", e.config.ArchiveRetentionDays) } diff --git a/pkg/types/config_test.go b/pkg/types/config_test.go index 2650ed1..bdfecd3 100644 --- a/pkg/types/config_test.go +++ b/pkg/types/config_test.go @@ -110,7 +110,12 @@ var _ = Describe("Config", func() { config.ConsiderOwnerReferences = true Ω(config.IsInstanceExcluded(res, us)).Should(BeTrue()) }) - It("if enabled it should be excluded if the owner is excluded", func() { + It("if enabled it should not be excluded if the owner is not excluded", func() { + us.SetOwnerReferences([]v1.OwnerReference{{APIVersion: "foofoo/v1", Kind: "Bar"}}) + config.ConsiderOwnerReferences = true + Ω(config.IsInstanceExcluded(res, us)).Should(BeFalse()) + }) + It("if disabled it should be not excluded if the owner is excluded", func() { config.ConsiderOwnerReferences = false Ω(config.IsInstanceExcluded(res, us)).Should(BeFalse()) })