From 872221186864acae2ae78c0384684c765cf3a358 Mon Sep 17 00:00:00 2001 From: Tomas Tormo Date: Wed, 28 Jun 2023 23:08:14 +0200 Subject: [PATCH] Add tests for ListEvent function --- modules/k8s/event_test.go | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/modules/k8s/event_test.go b/modules/k8s/event_test.go index 3e5c8f0acb..2f9f00d709 100644 --- a/modules/k8s/event_test.go +++ b/modules/k8s/event_test.go @@ -18,12 +18,20 @@ import ( _ "k8s.io/client-go/plugin/pkg/client/auth" ) +// Currently the Events API doesn't return an error even if a wrong namespace/filter is provided +func TestListEventsEReturnsNilErrorWhenListingEvents(t *testing.T) { + t.Parallel() + + options := NewKubectlOptions("", "", "non-existent-namespace") + _, err := ListEventsE(t, options, v1.ListOptions{}) + require.Nil(t, err) +} + func TestListEventsInNamespace(t *testing.T) { t.Parallel() options := NewKubectlOptions("", "", "kube-system") - events, err := ListEventsE(t, options, v1.ListOptions{}) - require.Nil(t, err) + events := ListEvents(t, options, v1.ListOptions{}) require.Greater(t, len(events), 0) } @@ -37,7 +45,6 @@ func TestListEventsReturnsZeroEventsIfNoneCreated(t *testing.T) { CreateNamespace(t, options, ns) options.Namespace = ns - events, err := ListEventsE(t, options, v1.ListOptions{}) - require.Nil(t, err) + events := ListEvents(t, options, v1.ListOptions{}) require.Equal(t, 0, len(events)) }