From 01f271a91733e01c6cfe42adaa0216a89f035dbe Mon Sep 17 00:00:00 2001 From: Aleksandar Faraj Date: Mon, 19 Dec 2022 22:26:23 +0100 Subject: [PATCH] TestList_AllNamespaces with namespace cases Updated the TestList_AllNamespaces to have different namespaces in the releases it tests with. Signed-off-by: Aleksandar Faraj --- pkg/action/list_test.go | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/pkg/action/list_test.go b/pkg/action/list_test.go index 73009d523..79d12c85c 100644 --- a/pkg/action/list_test.go +++ b/pkg/action/list_test.go @@ -79,7 +79,7 @@ func TestList_OneNamespace(t *testing.T) { func TestList_AllNamespaces(t *testing.T) { is := assert.New(t) lister := newListFixture(t) - makeMeSomeReleases(lister.cfg.Releases, t) + makeMeSomeReleasesWithDifferentNamespaces(lister.cfg.Releases, t) lister.AllNamespaces = true lister.SetStateMask() list, err := lister.Run() @@ -286,6 +286,34 @@ func makeMeSomeReleases(store *storage.Storage, t *testing.T) { assert.Len(t, all, 3, "sanity test: three items added") } + +func makeMeSomeReleasesWithDifferentNamespaces(store *storage.Storage, t *testing.T) { + t.Helper() + one := releaseStub() + one.Name = "one" + one.Namespace = "default1" + one.Version = 1 + two := releaseStub() + two.Name = "two" + two.Namespace = "default2" + two.Version = 2 + three := releaseStub() + three.Name = "three" + three.Namespace = "default3" + three.Version = 3 + + for _, rel := range []*release.Release{one, two, three} { + if err := store.Create(rel); err != nil { + t.Fatal(err) + } + } + + all, err := store.ListReleases() + assert.NoError(t, err) + assert.Len(t, all, 3, "sanity test: three items added") +} + + func TestFilterLatestReleases(t *testing.T) { t.Run("should filter old versions of the same release", func(t *testing.T) { r1 := releaseStub()