Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor odo exec integration tests + remove unused utils functions #5049

Merged
merged 2 commits into from
Sep 13, 2021

Conversation

feloy
Copy link
Contributor

@feloy feloy commented Sep 7, 2021

What type of PR is this?

/kind tests

What does this PR do / why we need it:

Which issue(s) this PR fixes:

Partially Fixes #4741

PR acceptance criteria:

How to test changes / Special notes to the reviewer:

Copy link
Member

@valaparthvi valaparthvi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apart from a few nitty-gritty changes, this looks good to me.

Do you think you can also accommodate a test for #5012 ?

args := []string{"create", "nodejs", cmpName, "--context", commonVar.Context}
helper.Cmd("odo", args...).ShouldPass()
helper.CopyExample(filepath.Join("source", "devfiles", "nodejs", "project"), commonVar.Context)
helper.CopyExampleDevFile(filepath.Join("source", "devfiles", "nodejs", "devfile.yaml"), filepath.Join(commonVar.Context, "devfile.yaml"))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to copy this devfile? Won't the devfile created by running odo create be enough?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems the PROJECTS_ROOT definition in the devfile.yaml is important. Some tests fail without copying this devfile.

It("should error out when a invalid command is given by the user", func() {
utils.ExecWithInvalidCommand(commonVar.Context, cmpName, "kube")
It("should error out when a component is not present or when a devfile flag is used", func() {
args := []string{"exec", "--context", commonVar.Context}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think something like the following would make sense in understanding the test easily. What do you think?

		It("should error out when a component is not present or when a devfile flag is used", func() {
			By("the component is not present")
			args := []string{"exec", "--context", commonVar.Context}
			args = append(args, []string{"--", "touch", "/projects/blah.js"}...)
			helper.Cmd("odo", args...).ShouldFail()

			By("the devfile flag is used")
			args = []string{"exec", "--context", commonVar.Context, "--devfile", "invalid.yaml"}
			args = append(args, []string{"--", "touch", "/projects/blah.js"}...)
			helper.Cmd("odo", args...).ShouldFail()
		})

Comment on lines 32 to 33
args := []string{"create", "nodejs", cmpName, "--context", commonVar.Context}
helper.Cmd("odo", args...).ShouldPass()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a new pattern that you're thinking of implementing? If so, I would like here more on it. If not, I would prefer if we simply use helper.Cmd("odo", "create", "nodejs", cmpName, "--context", commonVar.Context).ShouldPass() instead, I think it is more readable that way, or at least I have gotten used to reading it like that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I was keeping the previous syntax, but I will change with the syntax used anywhere else

Expect(output).To(ContainSubstring("no command was given"))
})

It("should error out when a invalid command is given by the user", func() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

an invalid command*

@sonarcloud
Copy link

sonarcloud bot commented Sep 13, 2021

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 2 Code Smells

No Coverage information No Coverage information
9.1% 9.1% Duplication

Copy link
Member

@dharmit dharmit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/approve
/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. Required by Prow. label Sep 13, 2021
@openshift-ci
Copy link

openshift-ci bot commented Sep 13, 2021

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: dharmit

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. Required by Prow. label Sep 13, 2021
@openshift-bot
Copy link

/retest-required

Please review the full test history for this PR and help us cut down flakes.

9 similar comments
@openshift-bot
Copy link

/retest-required

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link

/retest-required

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link

/retest-required

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link

/retest-required

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link

/retest-required

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link

/retest-required

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link

/retest-required

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link

/retest-required

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link

/retest-required

Please review the full test history for this PR and help us cut down flakes.

@openshift-merge-robot openshift-merge-robot merged commit c7e6424 into redhat-developer:main Sep 13, 2021
@dharmit
Copy link
Member

dharmit commented Sep 14, 2021

Partially Fixes #4741

Go for "Fixes part of #4741" next time. Else, GH will close the issue like it did this time. 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. Required by Prow. lgtm Indicates that a PR is ready to be merged. Required by Prow.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve tests readability and spec clean up
5 participants