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

Add ability to use mock without passing in arguments #191

Merged
merged 4 commits into from
Nov 30, 2023

Conversation

maysunfaisal
Copy link
Member

@maysunfaisal maysunfaisal commented Nov 28, 2023

What does this PR do?:

  • Adds the ability to use mock implementation without passing in mock data. Sometimes the client like HAS doesn't have the ability to pass in mock argument information always
  • If no token is passed, dont mock output

Which issue(s) this PR fixes:

PR acceptance criteria:

Testing and documentation do not need to be complete in order for this PR to be approved. We just need to ensure tracking issues are opened and linked to this PR, if they are not in the PR scope due to various constraints.

  • Unit/Functional tests

  • QE Integration test

  • Documentation (READMEs, Product Docs, Blogs, Education Modules, etc.)

  • Client Impact

  • Gosec scans

How to test changes / Special notes to the reviewer:

tests should pass

Signed-off-by: Maysun J Faisal <maysunaneek@gmail.com>
Copy link

codecov bot commented Nov 28, 2023

Codecov Report

Attention: 9 lines in your changes are missing coverage. Please review.

Comparison is base (38de98b) 60.53% compared to head (b1f8465) 60.46%.

❗ Current head b1f8465 differs from pull request most recent head c1944d6. Consider uploading reports for the commit c1944d6 to get more accurate results

Files Patch % Lines
pkg/devfile/parser/util/mock.go 64.28% 4 Missing and 1 partial ⚠️
pkg/util/mock.go 0.00% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #191      +/-   ##
==========================================
- Coverage   60.53%   60.46%   -0.07%     
==========================================
  Files          43       43              
  Lines        5047     5061      +14     
==========================================
+ Hits         3055     3060       +5     
- Misses       1802     1810       +8     
- Partials      190      191       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Signed-off-by: Maysun J Faisal <maysunaneek@gmail.com>
// So we should be adaptable and use the function params
// and mock the output
if util.IsGitProviderRepo(params.URL) {
gc.MockGitURL.Host = params.URL
Copy link
Collaborator

Choose a reason for hiding this comment

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

for this case, is it possible that gc.MockGitURL is nil?

Copy link
Member Author

Choose a reason for hiding this comment

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

Its not a pointer, I dont think we should check for nil here. Its a regular struct assignment.

mockGitUrl = gc.MockGitURL
mockGitUrl.Token = gc.GitTestToken
}
} else if params.URL != "" {
Copy link
Collaborator

Choose a reason for hiding this comment

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

can you add a test case for this block?

Copy link
Member Author

Choose a reason for hiding this comment

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

good catch, tests updated.

Signed-off-by: Maysun J Faisal <maysunaneek@gmail.com>
name: "Case 6: Input url is valid with a mock client",
client: MockDevfileUtilsClient{MockGitURL: util.MockGitUrl{Host: server.URL}, DownloadOptions: util.MockDownloadOptions{MockFile: "OK"}},
name: "Case 6: Input url is valid with a mock client, dont use mock data during invocation",
client: MockDevfileUtilsClient{},
url: server.URL,
Copy link
Collaborator

Choose a reason for hiding this comment

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

are we able to test a gitURL?

This comment was marked as outdated.

This comment was marked as outdated.

Copy link
Collaborator

Choose a reason for hiding this comment

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

since you add support for empty client, should add new unit test for your change, not editing the existing tests. the empty client case you added, needs a gitURL?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll add a Github URL

Signed-off-by: Maysun J Faisal <maysunaneek@gmail.com>
Copy link
Collaborator

@yangcao77 yangcao77 left a comment

Choose a reason for hiding this comment

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

looks good to me

Copy link

openshift-ci bot commented Nov 30, 2023

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: maysunfaisal, yangcao77
Once this PR has been reviewed and has the lgtm label, please assign elsony for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found 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

@maysunfaisal maysunfaisal merged commit 20a0c91 into devfile:main Nov 30, 2023
3 checks passed
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.

2 participants