Signed-off-by: Alex Jones <alexsimonjones@gmail.com>
This commit is contained in:
Alex Jones
2023-04-11 12:30:57 +01:00
parent 80ac51c804
commit 4984840de1
22 changed files with 170 additions and 85 deletions

View File

@@ -3,22 +3,23 @@ package analysis
import (
"encoding/json"
"fmt"
"github.com/k8sgpt-ai/k8sgpt/pkg/analyzer"
"github.com/stretchr/testify/require"
"testing"
"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()
@@ -40,7 +41,7 @@ func TestAnalysis_NoProblemJsonOutput(t *testing.T) {
func TestAnalysis_ProblemJsonOutput(t *testing.T) {
analysis := Analysis{
Results: []analyzer.Result{
Results: []common.Result{
{
"Deployment",
"test-deployment",
@@ -54,7 +55,7 @@ func TestAnalysis_ProblemJsonOutput(t *testing.T) {
expected := JsonOutput{
Status: StateProblemDetected,
Problems: 1,
Results: []analyzer.Result{
Results: []common.Result{
{"Deployment",
"test-deployment",
[]string{"test-problem"},
@@ -82,7 +83,7 @@ func TestAnalysis_ProblemJsonOutput(t *testing.T) {
func TestAnalysis_MultipleProblemJsonOutput(t *testing.T) {
analysis := Analysis{
Results: []analyzer.Result{
Results: []common.Result{
{
"Deployment",
"test-deployment",
@@ -96,7 +97,7 @@ func TestAnalysis_MultipleProblemJsonOutput(t *testing.T) {
expected := JsonOutput{
Status: StateProblemDetected,
Problems: 2,
Results: []analyzer.Result{
Results: []common.Result{
{"Deployment",
"test-deployment",
[]string{"test-problem", "another-test-problem"},