Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tatlat committed Feb 15, 2024
1 parent e5fd58a commit 4307954
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 8 deletions.
4 changes: 2 additions & 2 deletions pkg/workflows/create_prep_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func TestCreateNamespaceGetNamespaceFail(t *testing.T) {
namespace := "test-ns"

test.clientFactory.EXPECT().BuildClientFromKubeconfig(kubeconfig).Return(test.client, nil)
test.client.EXPECT().List(test.ctx, &corev1.NamespaceList{}).Return(fmt.Errorf(""))
test.client.EXPECT().List(test.ctx, gomock.AssignableToTypeOf(&corev1.NamespaceList{})).Return(fmt.Errorf(""))

err := workflows.CreateNamespaceIfNotPresent(test.ctx, namespace, kubeconfig, test.clientFactory)

Expand All @@ -110,7 +110,7 @@ func TestCreateNamespaceFail(t *testing.T) {
namespace := "test-ns"

test.clientFactory.EXPECT().BuildClientFromKubeconfig(kubeconfig).Return(test.client, nil)
test.client.EXPECT().List(test.ctx, &corev1.NamespaceList{}).Return(nil)
test.client.EXPECT().List(test.ctx, gomock.AssignableToTypeOf(&corev1.NamespaceList{})).Return(nil)
test.client.EXPECT().Create(test.ctx, newNamespace(namespace)).Return(fmt.Errorf(""))

err := workflows.CreateNamespaceIfNotPresent(test.ctx, namespace, kubeconfig, test.clientFactory)
Expand Down
13 changes: 10 additions & 3 deletions pkg/workflows/management/create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,9 +262,16 @@ func (c *createTestSetup) expectWriteClusterConfig() {
}

func (c *createTestSetup) expectCreateNamespace() {
ns := c.clusterSpec.Cluster.Namespace
c.client.EXPECT().Get(c.ctx, ns, "", &corev1.Namespace{}).MaxTimes(2)
c.client.EXPECT().Create(c.ctx, &corev1.Namespace{ObjectMeta: v1.ObjectMeta{Name: ns}}).MaxTimes(2)
n := c.clusterSpec.Cluster.Namespace
ns := &corev1.Namespace{
TypeMeta: v1.TypeMeta{
APIVersion: "v1",
Kind: "Namespace",
},
ObjectMeta: v1.ObjectMeta{Name: n},
}
c.client.EXPECT().List(c.ctx, gomock.AssignableToTypeOf(&corev1.NamespaceList{})).MaxTimes(2)
c.client.EXPECT().Create(c.ctx, ns).MaxTimes(2)
}

func (c *createTestSetup) expectDeleteBootstrap(err error) {
Expand Down
13 changes: 10 additions & 3 deletions pkg/workflows/workload/create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,16 @@ func (c *createTestSetup) expectSetup() {
}

func (c *createTestSetup) expectCreateNamespace() {
ns := c.clusterSpec.Cluster.Namespace
c.client.EXPECT().Get(c.ctx, ns, "", &corev1.Namespace{}).MaxTimes(2)
c.client.EXPECT().Create(c.ctx, &corev1.Namespace{ObjectMeta: v1.ObjectMeta{Name: ns}}).MaxTimes(2)
n := c.clusterSpec.Cluster.Namespace
ns := &corev1.Namespace{
TypeMeta: v1.TypeMeta{
APIVersion: "v1",
Kind: "Namespace",
},
ObjectMeta: v1.ObjectMeta{Name: n},
}
c.client.EXPECT().List(c.ctx, gomock.AssignableToTypeOf(&corev1.NamespaceList{})).MaxTimes(2)
c.client.EXPECT().Create(c.ctx, ns).MaxTimes(2)
}

func (c *createTestSetup) expectCreateWorkloadCluster(err1, err2 error) {
Expand Down

0 comments on commit 4307954

Please sign in to comment.