Skip to content

Commit

Permalink
Add more stupid tests without value
Browse files Browse the repository at this point in the history
  • Loading branch information
g-gaston committed Mar 24, 2023
1 parent b088d84 commit 7b917ad
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions pkg/clustermanager/kube_proxy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,18 @@ func TestKubeProxyUpgraderPrepareForUpgradeNoKCP(t *testing.T) {
).To(MatchError(ContainSubstring("reading the kubeadm control plane for an upgrade")))
}

func TestKubeProxyUpgraderPrepareForUpgradeNoKubeProxy(t *testing.T) {
g := NewWithT(t)
tt := newPrepareKubeProxyTest()
tt.kubeProxy = &appsv1.DaemonSet{} // no kube-proxy
tt.initClients(t)
u := clustermanager.NewKubeProxyUpgrader()

g.Expect(
u.PrepareForUpgrade(tt.ctx, tt.log, tt.managementClient, tt.workloadClient, tt.spec),
).To(MatchError(ContainSubstring("reading kube-proxy for upgrade")))
}

func TestKubeProxyUpgraderPrepareForUpgradeinvalidEKDDTag(t *testing.T) {
g := NewWithT(t)
tt := newPrepareKubeProxyTest()
Expand Down Expand Up @@ -359,6 +371,30 @@ func TestKubeProxyUpgraderCleanupAfterUpgradeSuccessWithReentry(t *testing.T) {
).To(Succeed())
}

func TestKubeProxyCleanupAfterUpgradeNoKubeProxy(t *testing.T) {
g := NewWithT(t)
tt := newPrepareKubeProxyTest()
tt.kubeProxy = &appsv1.DaemonSet{} // no kube-proxy
tt.initClients(t)
u := clustermanager.NewKubeProxyUpgrader()

g.Expect(
u.CleanupAfterUpgrade(tt.ctx, tt.log, tt.managementClient, tt.workloadClient, tt.spec),
).To(MatchError(ContainSubstring("reading kube-proxy for upgrade")))
}

func TestKubeProxyCleanupAfterUpgradeNoKCP(t *testing.T) {
g := NewWithT(t)
tt := newPrepareKubeProxyTest()
tt.kcp = &controlplanev1.KubeadmControlPlane{} // no kcp
tt.initClients(t)
u := clustermanager.NewKubeProxyUpgrader()

g.Expect(
u.CleanupAfterUpgrade(tt.ctx, tt.log, tt.managementClient, tt.workloadClient, tt.spec),
).To(MatchError(ContainSubstring("reading the kubeadm control plane to cleanup the skip annotations")))
}

func TestEKSDVersionAndNumberFromTag(t *testing.T) {
tests := []struct {
name string
Expand Down Expand Up @@ -576,3 +612,21 @@ func TestKubeProxyCLIUpgraderCleanupAfterUpgradeSuccess(t *testing.T) {
u.CleanupAfterUpgrade(tt.ctx, tt.spec, managementKubeConfig, workloadKubeConfig),
).To(Succeed())
}

func TestKubeProxyCLICleanupAfterUpgradeErrorWorkloadClusterClient(t *testing.T) {
g := NewWithT(t)
tt := newPrepareKubeProxyTest()
tt.initClients(t)
managementKubeConfig := "mngmt.yaml"
workloadKubeConfig := "workload.yaml"
ctrl := gomock.NewController(t)
factory := mocks.NewMockClientFactory(ctrl)
factory.EXPECT().BuildClientFromKubeconfig(managementKubeConfig).Return(tt.managementClient, nil)
factory.EXPECT().BuildClientFromKubeconfig(workloadKubeConfig).Return(nil, errors.New("building workload client"))

u := clustermanager.NewKubeProxyCLIUpgrader(test.NewNullLogger(), factory)

g.Expect(
u.CleanupAfterUpgrade(tt.ctx, tt.spec, managementKubeConfig, workloadKubeConfig),
).To(MatchError(ContainSubstring("building workload client")))
}

0 comments on commit 7b917ad

Please sign in to comment.