test: added tests for the PVC analyzer (#1000)

This commit introduces comprehensive tests for the
`PersistentVolumeClaim` analyzer defined in the `pkg/analyzer` package.

Adding these tests increases the code coverage of the `pvc.go` file to
>95%.

I also made minor modifications to the ReplicaSet test to ensure all
expectations were met.

Partially addresses: https://github.com/k8sgpt-ai/k8sgpt/issues/889

Signed-off-by: VaibhavMalik4187 <vaibhavmalik2018@gmail.com>
This commit is contained in:
Vaibhav Malik
2024-03-09 00:56:19 +05:30
committed by GitHub
parent b05b6a38ed
commit a0225d4f70
3 changed files with 223 additions and 5 deletions

View File

@@ -142,10 +142,10 @@ func TestReplicaSetAnalyzer(t *testing.T) {
},
}
for i, result := range results {
require.Equal(t, expectations[i].name, result.Name)
for j, failure := range result.Error {
require.Equal(t, expectations[i].failuresText[j], failure.Text)
for i, expectation := range expectations {
require.Equal(t, expectation.name, results[i].Name)
for j, failure := range results[i].Error {
require.Equal(t, expectation.failuresText[j], failure.Text)
}
}
}