Skip to content

Commit

Permalink
resolve failing tests redhat-developer#2
Browse files Browse the repository at this point in the history
  • Loading branch information
girishramnani committed Oct 11, 2019
1 parent ffb7820 commit b6804aa
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
13 changes: 10 additions & 3 deletions tests/integration/component.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,10 @@ func componentTests(args ...string) {
} else {
contextPath = strings.TrimSpace(context)
}
desired := fmt.Sprintf(`{"kind":"Component","apiVersion":"odo.openshift.io/v1alpha1","metadata":{"name":"nodejs","namespace":"%s","creationTimestamp":null},"spec":{"app":"app","type":"nodejs","source":"./","ports":["8080/TCP"]},"status":{"context":"%s","state":"Not Pushed"}}`, project, contextPath)
// this orders the json
desired, err := helper.Unindented(fmt.Sprintf(`{"kind":"Component","apiVersion":"odo.openshift.io/v1alpha1","metadata":{"name":"nodejs","namespace":"%s","creationTimestamp":null},"spec":{"app":"app","type":"nodejs","source":"./","ports":["8080/TCP"]},"status":{"context":"%s","state":"Not Pushed"}}`, project, contextPath))
Expect(err).Should(BeNil())

actual, err := helper.Unindented(helper.CmdShouldPass("odo", append(args, "list", "-o", "json", "--path", filepath.Dir(context))...))
Expect(err).Should(BeNil())
// since the tests are run parallel, there might be many odo component directories in the root folder
Expand Down Expand Up @@ -142,9 +145,13 @@ func componentTests(args ...string) {
helper.Chdir(context)
helper.DeleteDir(context2)
helper.DeleteProject(project2)
expected := fmt.Sprintf(`{"kind":"Component","apiVersion":"odo.openshift.io/v1alpha1","metadata":{"name":"nodejs","namespace":"%s","creationTimestamp":null},"spec":{"app":"app","type":"nodejs","source":"./","ports":["8080/TCP"]},"status":{"context":"%s","state":"Pushed"}}`, project, contextPath)
// this orders the json
expected, err := helper.Unindented(fmt.Sprintf(`{"kind":"Component","apiVersion":"odo.openshift.io/v1alpha1","metadata":{"name":"nodejs","namespace":"%s","creationTimestamp":null},"spec":{"app":"app","type":"nodejs","source":"./","ports":["8080/TCP"]},"status":{"context":"%s","state":"Pushed"}}`, project, contextPath))
Expect(err).Should(BeNil())
Expect(actual).Should(ContainSubstring(expected))
expected = fmt.Sprintf(`{"kind":"Component","apiVersion":"odo.openshift.io/v1alpha1","metadata":{"name":"python","namespace":"%s","creationTimestamp":null},"spec":{"app":"app","type":"python","source":"./","ports":["8080/TCP"]},"status":{"context":"%s","state":"Pushed"}}`, project2, contextPath2)
// this orders the json
expected, err = helper.Unindented(fmt.Sprintf(`{"kind":"Component","apiVersion":"odo.openshift.io/v1alpha1","metadata":{"name":"python","namespace":"%s","creationTimestamp":null},"spec":{"app":"app","type":"python","source":"./","ports":["8080/TCP"]},"status":{"context":"%s","state":"Pushed"}}`, project2, contextPath2))
Expect(err).Should(BeNil())
Expect(actual).Should(ContainSubstring(expected))

})
Expand Down
5 changes: 3 additions & 2 deletions tests/integration/project/cmd_project_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,15 @@ var _ = Describe("odo project command tests", func() {
})

Context("when running project command app parameter in directory that doesn't contain .odo config directory", func() {
It("should successfully execute list along with machine readable output", func() {
FIt("should successfully execute list along with machine readable output", func() {
listOutput := helper.CmdShouldPass("odo", "project", "list")
Expect(listOutput).To(ContainSubstring(project))

// project deletion doesn't happen immediately, so we test subset of the string
listOutputJSON, err := helper.Unindented(helper.CmdShouldPass("odo", "project", "list", "-o", "json"))
Expect(err).Should(BeNil())
expected := `{"kind":"Project","apiVersion":"odo.openshift.io/v1alpha1","metadata":{"name":"` + project + `","namespace":"` + project + `","creationTimestamp":null},"spec":{},"status":{"active":true}}`
expected, err := helper.Unindented(`{"kind":"Project","apiVersion":"odo.openshift.io/v1alpha1","metadata":{"name":"` + project + `","namespace":"` + project + `","creationTimestamp":null},"spec":{},"status":{"active":true}}`)
Expect(err).Should(BeNil())
Expect(listOutputJSON).To(ContainSubstring(expected))
})
})
Expand Down

0 comments on commit b6804aa

Please sign in to comment.