Merge pull request #5221 from mohamedawnallah/testKarmadactlOptionsCommand

test/e2e/karmadactl_test.go: test options command
This commit is contained in:
karmada-bot 2024-07-23 20:33:15 +08:00 committed by GitHub
commit 721495dcf2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 18 additions and 0 deletions

View File

@ -1136,6 +1136,24 @@ var _ = ginkgo.Describe("Karmadactl token testing", func() {
})
})
var _ = ginkgo.Describe("Karmadactl options testing", func() {
ginkgo.Context("Test karmadactl options command", func() {
ginkgo.It("should list available options successfully", func() {
cmd := framework.NewKarmadactlCommand(kubeconfig, "", karmadactlPath, "", karmadactlTimeout, "options")
output, err := cmd.ExecOrDie()
gomega.Expect(err).ShouldNot(gomega.HaveOccurred())
gomega.Expect(strings.Contains(output, "The following options can be passed to any command")).Should(gomega.BeTrue())
})
ginkgo.It("should return error for invalid flag in options", func() {
cmd := framework.NewKarmadactlCommand(kubeconfig, "", karmadactlPath, "", karmadactlTimeout, "options", "--invalidflag")
_, err := cmd.ExecOrDie()
gomega.Expect(err).Should(gomega.HaveOccurred())
gomega.Expect(strings.Contains(err.Error(), "unknown flag: --invalidflag")).Should(gomega.BeTrue())
})
})
})
// extractTokenIDAndSecret extracts the token ID and Secret from the output string.
// It assumes the output format is "tokenID.tokenSecret".
//