mirror of
https://github.com/k8sgpt-ai/k8sgpt.git
synced 2026-01-25 14:54:20 +00:00
* chore: analyzer and ai interfacing Signed-off-by: Thomas Schuetz <thomas.schuetz@t-sc.eu> * fix: backend variable for aiProvider in cmd Signed-off-by: Thomas Schuetz <thomas.schuetz@t-sc.eu> * fix: changed folders for analyzers Signed-off-by: Thomas Schuetz <thomas.schuetz@t-sc.eu> * chore: renamed analyzers Signed-off-by: Thomas Schuetz <thomas.schuetz@t-sc.eu> * fix: fixed ingress tests after rebase Signed-off-by: Thomas Schuetz <thomas.schuetz@t-sc.eu> * fix: fixed ingress tests after rebase Signed-off-by: Thomas Schuetz <thomas.schuetz@t-sc.eu> --------- Signed-off-by: Thomas Schuetz <thomas.schuetz@t-sc.eu>
49 lines
1.1 KiB
Go
49 lines
1.1 KiB
Go
package analyzer
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
"github.com/k8sgpt-ai/k8sgpt/pkg/kubernetes"
|
|
"github.com/magiconair/properties/assert"
|
|
v1 "k8s.io/api/core/v1"
|
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
|
"k8s.io/client-go/kubernetes/fake"
|
|
)
|
|
|
|
func TestPodAnalyzer(t *testing.T) {
|
|
|
|
clientset := fake.NewSimpleClientset(&v1.Pod{
|
|
ObjectMeta: metav1.ObjectMeta{
|
|
Name: "example",
|
|
Namespace: "default",
|
|
Annotations: map[string]string{},
|
|
},
|
|
Status: v1.PodStatus{
|
|
Phase: v1.PodPending,
|
|
Conditions: []v1.PodCondition{
|
|
{
|
|
Type: v1.PodScheduled,
|
|
Reason: "Unschedulable",
|
|
Message: "0/1 nodes are available: 1 node(s) had taint {node-role.kubernetes.io/master: }, that the pod didn't tolerate.",
|
|
},
|
|
},
|
|
},
|
|
})
|
|
|
|
config := Analyzer{
|
|
Client: &kubernetes.Client{
|
|
Client: clientset,
|
|
},
|
|
Context: context.Background(),
|
|
Namespace: "default",
|
|
}
|
|
podAnalyzer := PodAnalyzer{}
|
|
var analysisResults []Result
|
|
analysisResults, err := podAnalyzer.Analyze(config)
|
|
if err != nil {
|
|
t.Error(err)
|
|
}
|
|
assert.Equal(t, len(analysisResults), 1)
|
|
}
|