mirror of
https://github.com/k8sgpt-ai/k8sgpt.git
synced 2026-01-25 23:03:57 +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>
50 lines
1.0 KiB
Go
50 lines
1.0 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 TestServiceAnalyzer(t *testing.T) {
|
|
|
|
clientset := fake.NewSimpleClientset(&v1.Endpoints{
|
|
ObjectMeta: metav1.ObjectMeta{
|
|
Name: "example",
|
|
Namespace: "default",
|
|
Annotations: map[string]string{},
|
|
},
|
|
},
|
|
&v1.Service{
|
|
ObjectMeta: metav1.ObjectMeta{
|
|
Name: "example",
|
|
Namespace: "default",
|
|
Annotations: map[string]string{},
|
|
},
|
|
Spec: v1.ServiceSpec{
|
|
Selector: map[string]string{
|
|
"app": "example",
|
|
},
|
|
}})
|
|
|
|
config := Analyzer{
|
|
Client: &kubernetes.Client{
|
|
Client: clientset,
|
|
},
|
|
Context: context.Background(),
|
|
Namespace: "default",
|
|
}
|
|
|
|
serviceAnalyzer := ServiceAnalyzer{}
|
|
analysisResults, err := serviceAnalyzer.Analyze(config)
|
|
if err != nil {
|
|
t.Error(err)
|
|
}
|
|
assert.Equal(t, len(analysisResults), 1)
|
|
}
|