chore: updated analysis_test.go

Signed-off-by: chetan gupta <chetangupta123raj@gmail.com>
This commit is contained in:
chetan gupta 2023-04-11 20:59:41 +05:30
parent 21dc61c04f
commit 825e9a43bd

View File

@ -3,9 +3,10 @@ package analysis
import ( import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"testing"
"github.com/k8sgpt-ai/k8sgpt/pkg/analyzer" "github.com/k8sgpt-ai/k8sgpt/pkg/analyzer"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"testing"
) )
func TestAnalysis_NoProblemJsonOutput(t *testing.T) { func TestAnalysis_NoProblemJsonOutput(t *testing.T) {
@ -42,11 +43,12 @@ func TestAnalysis_ProblemJsonOutput(t *testing.T) {
analysis := Analysis{ analysis := Analysis{
Results: []analyzer.Result{ Results: []analyzer.Result{
{ {
"Deployment", Kind: "Deployment",
"test-deployment", Name: "test-deployment",
[]string{"test-problem"}, Error: []string{"test-problem"},
"test-solution", Details: "test-solution",
"parent-resource"}, ParentObject: "parent-resource",
},
}, },
Namespace: "default", Namespace: "default",
} }
@ -55,11 +57,13 @@ func TestAnalysis_ProblemJsonOutput(t *testing.T) {
Status: StateProblemDetected, Status: StateProblemDetected,
Problems: 1, Problems: 1,
Results: []analyzer.Result{ Results: []analyzer.Result{
{"Deployment", {
"test-deployment", Kind: "Deployment",
[]string{"test-problem"}, Name: "test-deployment",
"test-solution", Error: []string{"test-problem"},
"parent-resource"}, Details: "test-solution",
ParentObject: "parent-resource",
},
}, },
} }
@ -84,11 +88,12 @@ func TestAnalysis_MultipleProblemJsonOutput(t *testing.T) {
analysis := Analysis{ analysis := Analysis{
Results: []analyzer.Result{ Results: []analyzer.Result{
{ {
"Deployment", Kind: "Deployment",
"test-deployment", Name: "test-deployment",
[]string{"test-problem", "another-test-problem"}, Error: []string{"test-problem", "another-test-problem"},
"test-solution", Details: "test-solution",
"parent-resource"}, ParentObject: "parent-resource",
},
}, },
Namespace: "default", Namespace: "default",
} }
@ -97,11 +102,13 @@ func TestAnalysis_MultipleProblemJsonOutput(t *testing.T) {
Status: StateProblemDetected, Status: StateProblemDetected,
Problems: 2, Problems: 2,
Results: []analyzer.Result{ Results: []analyzer.Result{
{"Deployment", {
"test-deployment", Kind: "Deployment",
[]string{"test-problem", "another-test-problem"}, Name: "test-deployment",
"test-solution", Error: []string{"test-problem", "another-test-problem"},
"parent-resource"}, Details: "test-solution",
ParentObject: "parent-resource",
},
}, },
} }