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

[tests-only][full-ci] removing the setResponse() in given/then step in GraphContext #7399

Merged
merged 1 commit into from
Oct 31, 2023

Conversation

nirajacharya2
Copy link
Contributor

@nirajacharya2 nirajacharya2 commented Oct 3, 2023

Description

We have used setResponse() and $this->response in the Given/Then steps and some helper functions (maybe to reuse existing available methods). But storing responses from Given/Then steps and helper functions is not a good idea because it can lead to a false positive assertion in the Then steps.
So, check the use of setResponse() and $this->response in

  • Given steps
  • Then steps (Then steps can use $this->response but must prevent saving to it)
  • Helper functions

Related Issue

part of: #7082

Motivation and Context

  • To remove setResponse() and $this->response in the Given/Then steps and some helper functions
  • To avoid false positive assertions

How Has This Been Tested?

  • test environment:
  • locally
  • CI

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Technical debt
  • Tests only (no source changes)

Checklist:

  • Code changes
  • Unit tests added
  • Acceptance tests added
  • Documentation ticket raised:

@phil-davis phil-davis changed the title refactor [tests-only] refactor Oct 3, 2023
@owncloud owncloud deleted a comment from update-docs bot Oct 3, 2023
@phil-davis
Copy link
Contributor

@nirajacharya2 please write more in the PR title.
I added [tests-only] - for PRs with only test code changes, we should always put that in the PR title.
But also, please write more than just "refactor" (even though the PR is in draft, it is nicer to have a few words about what it will be)

@nirajacharya2 nirajacharya2 changed the title [tests-only] refactor [tests-only] removing the setResponse() in given/then step in GraphContext Oct 5, 2023
@nirajacharya2 nirajacharya2 self-assigned this Oct 5, 2023
@nirajacharya2 nirajacharya2 force-pushed the refactor-graph-context branch 14 times, most recently from 41ed89b to befe277 Compare October 10, 2023 11:30
@nirajacharya2 nirajacharya2 changed the title [tests-only] removing the setResponse() in given/then step in GraphContext [tests-only][full-ci] removing the setResponse() in given/then step in GraphContext Oct 10, 2023
@nirajacharya2 nirajacharya2 force-pushed the refactor-graph-context branch 9 times, most recently from 7f53d2b to 57c2f3c Compare October 12, 2023 09:13
Comment on lines 1454 to 1458
if ($response === $response) {
$responseBody = $this->getJsonDecodedResponseBodyContent($response);
} else {
$responseBody = $this->getJsonDecodedResponseBodyContent();
}
Copy link
Contributor

Choose a reason for hiding this comment

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

$response = $response ?? $this->response;
$responseBody = $this->getJsonDecodedResponseBodyContent($response);

@@ -1445,13 +1445,17 @@ public function theOcsDataOfTheResponseShouldMatch(
* @Then the JSON data of the response should match
*
* @param PyStringNode $schemaString
* @param ResponseInterface $response
Copy link
Contributor

Choose a reason for hiding this comment

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

@param ResponseInterface|null $response

Copy link
Contributor

@SwikritiT SwikritiT left a comment

Choose a reason for hiding this comment

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

lgtm

@sonarcloud
Copy link

sonarcloud bot commented Oct 30, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

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

No Coverage information No Coverage information
No Duplication information No Duplication information

Copy link
Member

@SagarGi SagarGi left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@saw-jan saw-jan merged commit cbfd894 into master Oct 31, 2023
2 checks passed
@delete-merged-branch delete-merged-branch bot deleted the refactor-graph-context branch October 31, 2023 06:32
ownclouders pushed a commit that referenced this pull request Oct 31, 2023
Co-authored-by: Sawjan Gurung <saw.jan.grg3e@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants