Skip to content

Commit

Permalink
Fix appset tests
Browse files Browse the repository at this point in the history
Signed-off-by: Adrian Aneci <aneci@adobe.com>
  • Loading branch information
adriananeci committed Dec 9, 2024
1 parent 5122722 commit 61a3db6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,7 @@ func TestCreateOrUpdateInCluster(t *testing.T) {
},
Spec: v1alpha1.ApplicationSpec{
Project: "project",
Source: &v1alpha1.ApplicationSource{
Source: &v1alpha1.ApplicationSource{
// Directory and jsonnet block are removed
},
},
Expand Down
10 changes: 10 additions & 0 deletions applicationset/utils/clusterUtils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/kubernetes/fake"
kubetesting "k8s.io/client-go/testing"

Expand Down Expand Up @@ -93,6 +94,15 @@ func TestValidateDestination(t *testing.T) {
Namespace: "default",
}

// Save current function and restore at the end:
oldListClustersFunc := ListClustersFunc
defer func() { ListClustersFunc = oldListClustersFunc }()

testCluster := argoappv1.Cluster{Server: "https://127.0.0.1:6443", Name: "test-cluster"}
ListClustersFunc = func(ctx context.Context, clientset kubernetes.Interface, namespace string) (*argoappv1.ClusterList, error) {
return &argoappv1.ClusterList{Items: []argoappv1.Cluster{testCluster}}, nil
}

appCond := ValidateDestination(context.Background(), &dest, nil, fakeNamespace)
require.NoError(t, appCond)
assert.False(t, dest.IsServerInferred())
Expand Down

0 comments on commit 61a3db6

Please sign in to comment.