feat: refactor integration to use Failure object

Signed-off-by: Matthis Holleville <matthish29@gmail.com>
This commit is contained in:
Matthis Holleville
2023-04-12 11:40:51 +02:00
35 changed files with 1394 additions and 160 deletions

View File

@@ -5,21 +5,21 @@ import (
"fmt"
"testing"
"github.com/k8sgpt-ai/k8sgpt/pkg/analyzer"
"github.com/k8sgpt-ai/k8sgpt/pkg/common"
"github.com/stretchr/testify/require"
)
func TestAnalysis_NoProblemJsonOutput(t *testing.T) {
analysis := Analysis{
Results: []analyzer.Result{},
Results: []common.Result{},
Namespace: "default",
}
expected := JsonOutput{
Status: StateOK,
Problems: 0,
Results: []analyzer.Result{},
Results: []common.Result{},
}
gotJson, err := analysis.JsonOutput()
@@ -41,14 +41,14 @@ func TestAnalysis_NoProblemJsonOutput(t *testing.T) {
func TestAnalysis_ProblemJsonOutput(t *testing.T) {
analysis := Analysis{
Results: []analyzer.Result{
Results: []common.Result{
{
Kind: "Deployment",
Name: "test-deployment",
Error: []analyzer.Failure{
Error: []common.Failure{
{
Text: "test-problem",
Sensitive: []analyzer.Sensitive{},
Sensitive: []common.Sensitive{},
},
},
Details: "test-solution",
@@ -60,14 +60,14 @@ func TestAnalysis_ProblemJsonOutput(t *testing.T) {
expected := JsonOutput{
Status: StateProblemDetected,
Problems: 1,
Results: []analyzer.Result{
Results: []common.Result{
{
Kind: "Deployment",
Name: "test-deployment",
Error: []analyzer.Failure{
Error: []common.Failure{
{
Text: "test-problem",
Sensitive: []analyzer.Sensitive{},
Sensitive: []common.Sensitive{},
},
},
Details: "test-solution",
@@ -94,18 +94,18 @@ func TestAnalysis_ProblemJsonOutput(t *testing.T) {
func TestAnalysis_MultipleProblemJsonOutput(t *testing.T) {
analysis := Analysis{
Results: []analyzer.Result{
Results: []common.Result{
{
Kind: "Deployment",
Name: "test-deployment",
Error: []analyzer.Failure{
Error: []common.Failure{
{
Text: "test-problem",
Sensitive: []analyzer.Sensitive{},
Sensitive: []common.Sensitive{},
},
{
Text: "another-test-problem",
Sensitive: []analyzer.Sensitive{},
Sensitive: []common.Sensitive{},
},
},
Details: "test-solution",
@@ -117,18 +117,18 @@ func TestAnalysis_MultipleProblemJsonOutput(t *testing.T) {
expected := JsonOutput{
Status: StateProblemDetected,
Problems: 2,
Results: []analyzer.Result{
Results: []common.Result{
{
Kind: "Deployment",
Name: "test-deployment",
Error: []analyzer.Failure{
Error: []common.Failure{
{
Text: "test-problem",
Sensitive: []analyzer.Sensitive{},
Sensitive: []common.Sensitive{},
},
{
Text: "another-test-problem",
Sensitive: []analyzer.Sensitive{},
Sensitive: []common.Sensitive{},
},
},
Details: "test-solution",