Skip to content

Commit

Permalink
test/e2e/karmadactl_test.go: test version command
Browse files Browse the repository at this point in the history
In this commit, we test `karmadactl version` command to
make sure it return valid information and return error
when invalid flag is provided.

Signed-off-by: Mohamed Awnallah <mohamedmohey2352@gmail.com>
  • Loading branch information
mohamedawnallah committed Jul 15, 2024
1 parent d3adcf6 commit c612a44
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions test/e2e/karmadactl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -610,3 +610,24 @@ var _ = ginkgo.Describe("Karmadactl top testing", ginkgo.Labels{NeedCreateCluste
})
})
})

var _ = ginkgo.Describe("Karmadactl version testing", func() {
ginkgo.Context("Test karmadactl version command", func() {
ginkgo.It("should return the version information successfully", func() {
cmd := framework.NewKarmadactlCommand(kubeconfig, "", karmadactlPath, "", karmadactlTimeout, "version")
output, err := cmd.ExecOrDie()
gomega.Expect(err).ShouldNot(gomega.HaveOccurred())
gomega.Expect(strings.Contains(output, "karmadactl version")).Should(gomega.BeTrue())
gomega.Expect(strings.Contains(output, "GitVersion")).Should(gomega.BeTrue())
gomega.Expect(strings.Contains(output, "GoVersion")).Should(gomega.BeTrue())
gomega.Expect(strings.Contains(output, "Platform")).Should(gomega.BeTrue())
})

ginkgo.It("should return error for invalid flag", func() {
cmd := framework.NewKarmadactlCommand(kubeconfig, "", karmadactlPath, "", karmadactlTimeout, "version", "--invalidflag")
_, err := cmd.ExecOrDie()
gomega.Expect(err).Should(gomega.HaveOccurred())
gomega.Expect(strings.Contains(err.Error(), "unknown flag: --invalidflag")).Should(gomega.BeTrue())
})
})
})

0 comments on commit c612a44

Please sign in to comment.