Skip to content

Commit

Permalink
Add tests for ListEvent function
Browse files Browse the repository at this point in the history
  • Loading branch information
kaisoz committed Jun 28, 2023
1 parent 4a22239 commit 8722211
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions modules/k8s/event_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand All @@ -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))
}

0 comments on commit 8722211

Please sign in to comment.