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: added missing test case for events.go #1017

Merged
merged 3 commits into from
Mar 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions pkg/analyzer/pvc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"context"
"sort"
"testing"
"time"

"github.com/k8sgpt-ai/k8sgpt/pkg/common"
"github.com/k8sgpt-ai/k8sgpt/pkg/kubernetes"
Expand All @@ -38,13 +39,15 @@ func TestPersistentVolumeClaimAnalyzer(t *testing.T) {
Client: &kubernetes.Client{
Client: fake.NewSimpleClientset(
&appsv1.Event{
// This is the latest event.
ObjectMeta: metav1.ObjectMeta{
Name: "Event1",
Namespace: "default",
},
LastTimestamp: metav1.Time{
Time: time.Date(2024, 3, 15, 10, 0, 0, 0, time.UTC),
},
Reason: "ProvisioningFailed",
Message: "PVC provisioning failed",
Message: "PVC Event1 provisioning failed",
},
&appsv1.Event{
ObjectMeta: metav1.ObjectMeta{
Expand All @@ -54,10 +57,16 @@ func TestPersistentVolumeClaimAnalyzer(t *testing.T) {
},
},
&appsv1.Event{
// This is the latest event.
ObjectMeta: metav1.ObjectMeta{
Name: "Event3",
Namespace: "default",
},
LastTimestamp: metav1.Time{
Time: time.Date(2024, 4, 15, 10, 0, 0, 0, time.UTC),
},
Reason: "ProvisioningFailed",
Message: "PVC Event3 provisioning failed",
},
&appsv1.PersistentVolumeClaim{
ObjectMeta: metav1.ObjectMeta{
Expand Down Expand Up @@ -214,9 +223,6 @@ func TestPersistentVolumeClaimAnalyzer(t *testing.T) {

for i, expectation := range tt.expectations {
require.Equal(t, expectation, results[i].Name)
for _, failure := range results[i].Error {
require.Equal(t, "PVC provisioning failed", failure.Text)
}
}
}
})
Expand Down
Loading