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 test cases for viewing specific patterns by name #11166

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

yash37158
Copy link
Member

Notes for Reviewers
This PR adds test cases to the Meshery project to verify the ability to view specific patterns based on their names within a design file. The new test cases cover both successful retrieval and handling of non-existent patterns, enhancing the pattern package's functionality.

This PR fixes #11107

  • Implemented test case to verify viewing a specific pattern by its name.
  • Added scenarios for successful retrieval of a pattern by name.
  • Added scenarios for handling non-existent patterns.
  • Mocked HTTP responses for the new test cases.
  • Updated existing test structure to incorporate the new scenarios.
  • Ensured proper logging and error handling within the test cases.

Signed commits

  • Yes, I signed my commits.

Signed-off-by: yash37158 <yash37158@gmail.com>
@github-actions github-actions bot added the component/mesheryctl CLI for Meshery label Jun 12, 2024
Copy link

github-actions bot commented Jun 12, 2024

Copy link

codecov bot commented Jun 12, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 9.21%. Comparing base (0bbdd7f) to head (2e86590).
Report is 126 commits behind head on master.

Current head 2e86590 differs from pull request most recent head 8fd1dce

Please upload reports for the commit 8fd1dce to get more accurate results.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #11166      +/-   ##
==========================================
+ Coverage    9.11%    9.21%   +0.09%     
==========================================
  Files         146      146              
  Lines       19303    19303              
==========================================
+ Hits         1760     1778      +18     
+ Misses      17241    17215      -26     
- Partials      302      310       +8     
Flag Coverage Δ
unittests 9.21% <ø> (+0.09%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

@Deepak0320Singhal
Copy link

@yash37158 Thank you for your contributions.
Let's discuss this on Websites's call on Monday. Adding this as an agenda item into the meeting minutes.

@leecalcote
Copy link
Member

It’s great to see this PR. 🤠

@leecalcote
Copy link
Member

@DevRish would you like to review this PR and offer comment?

URLs: []utils.MockURL{
{
Method: "GET",
URL: "https://raw.githubusercontent.com/yash37158/SamplePattern/main/samplepatternwithservicemesh.golden",
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it is best to keep test related assets within this repo itself and not have dependency on files from external repositories.
We have a similar design file in the fixtures directory here.
We can use a link to that instead (https://raw.githubusercontent.com/meshery/meshery/master/mesheryctl/internal/cli/root/pattern/fixtures/pattern.golden)

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes sure @DevRish

Args: []string{"view", "design"},
ExpectedResponse: "view.pattern.output.golden",
Fixture: "view.pattern.api.response.golden",
URL: testContext.BaseURL + "/api/pattern?name=Untitled Design",
Copy link
Contributor

Choose a reason for hiding this comment

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

Currently a design with this name exists. But if gets deleted in the future, this test might fail. We could add a block before this to upload a design with a name, and then use that name in this block. This will ensure that the file always exists when the test runs...

Args: []string{"view", "design"},
ExpectedResponse: "view.pattern.output.golden",
Fixture: "view.pattern.api.response.golden",
URL: testContext.BaseURL + "/api/pattern?name=NonExistentDesign",
Copy link
Contributor

@DevRish DevRish Jun 23, 2024

Choose a reason for hiding this comment

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

Similar concern here. A file with this name currently doesn't exist, but if it does get created somehow in the future, this test might fail... Can we somehow ensure that the design doesn't exist before using that design's name in this test?

@leecalcote
Copy link
Member

Thanks, @DevRish 👍

@leecalcote
Copy link
Member

It'd be great to have this as a point of discussion on tomorrow's Meshery Build and Release call.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/mesheryctl CLI for Meshery
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[mesheryctl] Enhance Mesheryctl Pattern Subcommand Tests
4 participants