mirror of
https://github.com/k8sgpt-ai/k8sgpt.git
synced 2025-09-09 03:01:16 +00:00
feat: refactor integration to use Failure object
Signed-off-by: Matthis Holleville <matthish29@gmail.com>
This commit is contained in:
@@ -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",
|
||||
|
Reference in New Issue
Block a user