Skip to content

Commit

Permalink
refactoring generic-test (redhat-developer#5628)
Browse files Browse the repository at this point in the history
* rebasing

* Incorporated additional feedback, removed make test-generic from openshift-tests.sh as it runs test-integration
  • Loading branch information
rnapoles-rh authored and cdrage committed Aug 31, 2022
1 parent 1717725 commit 3eb05d3
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 31 deletions.
2 changes: 2 additions & 0 deletions .ibm/pipelines/kubernetes-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ cleanup_namespaces
make test-interactive
make test-e2e-devfile
make test-cmd-project
make test-generic
) |& tee "/tmp/${LOGFILE}"

RESULT=${PIPESTATUS[0]}

save_logs "${LOGFILE}" "Kubernetes Tests" ${RESULT}
Expand Down
1 change: 1 addition & 0 deletions .ibm/pipelines/openshift-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ cleanup_namespaces
make test-cmd-project
make test-e2e-devfile
) |& tee "/tmp/${LOGFILE}"

RESULT=${PIPESTATUS[0]}

save_logs "${LOGFILE}" "OpenShift Tests" ${RESULT}
Expand Down
65 changes: 34 additions & 31 deletions tests/integration/generic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package integration

import (
"regexp"
"strings"

. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
Expand All @@ -27,64 +26,68 @@ var _ = Describe("odo generic", func() {
helper.CommonAfterEach(commonVar)
})

Context("Check the help usage for odo", func() {

It("Makes sure that we have the long-description when running odo and we dont error", func() {
output := helper.Cmd("odo").ShouldPass().Out()
Expect(output).To(ContainSubstring("To see a full list of commands, run 'odo --help'"))
When("running odo --help", func() {
var output string
BeforeEach(func() {
output = helper.Cmd("odo", "--help").ShouldPass().Out()
})

It("Make sure we have the full description when performing odo --help", func() {
output := helper.Cmd("odo", "--help").ShouldPass().Out()
Expect(output).To(ContainSubstring("Use \"odo [command] --help\" for more information about a command."))
It("retuns full help contents including usage, examples, commands, utility commands, component shortcuts, and flags sections", func() {
helper.MatchAllInOutput(output, []string{"Usage:", "Examples:", "Main Commands:", "OpenShift Commands:", "Utility Commands:", "Flags:"})
})

It("Fail when entering an incorrect name for a component", func() {
output := helper.Cmd("odo", "delete", "foobar").ShouldFail().Err()
Expect(output).To(ContainSubstring("Subcommand not found, use one of the available commands"))
})
})

It("Fail with showing help only once for incorrect command", func() {
output := helper.Cmd("odo", "hello").ShouldFail().Err()
Expect(strings.Count(output, "odo [flags]")).Should(Equal(1))
When("running odo without subcommand and flags", func() {
var output string
BeforeEach(func() {
output = helper.Cmd("odo").ShouldPass().Out()
})
It("a short vesion of help contents is returned, an error is not expected", func() {
Expect(output).To(ContainSubstring("To see a full list of commands, run 'odo --help'"))
})
})

It("returns error when using an invalid command", func() {
output := helper.Cmd("odo", "hello").ShouldFail().Err()
Expect(output).To(ContainSubstring("Invalid command - see available commands/subcommands above"))
})

Context("When deleting two project one after the other", func() {
It("should be able to delete sequentially", func() {
project1 := helper.CreateRandProject()
project2 := helper.CreateRandProject()

helper.DeleteProject(project2)
helper.DeleteProject(project1)
helper.DeleteProject(project2)
})
})

Context("When deleting three project one after the other in opposite order", func() {
It("should be able to delete", func() {
It("should be able to delete them in any order", func() {
project1 := helper.CreateRandProject()
project2 := helper.CreateRandProject()
project3 := helper.CreateRandProject()

helper.DeleteProject(project1)
helper.DeleteProject(project2)
helper.DeleteProject(project1)
helper.DeleteProject(project3)

})
})

Context("when executing odo version command", func() {
When("executing odo version command", func() {
var odoVersion string
BeforeEach(func() {
odoVersion = helper.Cmd("odo", "version").ShouldPass().Out()
})

It("should show the version of odo major components including server login URL", func() {
odoVersion := helper.Cmd("odo", "version").ShouldPass().Out()
reOdoVersion := regexp.MustCompile(`^odo\s*v[0-9]+.[0-9]+.[0-9]+(?:-\w+)?\s*\(\w+\)`)
odoVersionStringMatch := reOdoVersion.MatchString(odoVersion)
rekubernetesVersion := regexp.MustCompile(`Kubernetes:\s*v[0-9]+.[0-9]+.[0-9]+((-\w+\.[0-9]+)?\+\w+)?`)
kubernetesVersionStringMatch := rekubernetesVersion.MatchString(odoVersion)
Expect(odoVersionStringMatch).Should(BeTrue())
Expect(kubernetesVersionStringMatch).Should(BeTrue())
serverURL := oc.GetCurrentServerURL()
Expect(odoVersion).Should(ContainSubstring("Server: " + serverURL))
if !helper.IsKubernetesCluster() {
rekubernetesVersion := regexp.MustCompile(`Kubernetes:\s*v[0-9]+.[0-9]+.[0-9]+((-\w+\.[0-9]+)?\+\w+)?`)
kubernetesVersionStringMatch := rekubernetesVersion.MatchString(odoVersion)
Expect(kubernetesVersionStringMatch).Should(BeTrue())
serverURL := oc.GetCurrentServerURL()
Expect(odoVersion).Should(ContainSubstring("Server: " + serverURL))
}
})
})

Expand Down

0 comments on commit 3eb05d3

Please sign in to comment.