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 unit test for cli #274

Merged
merged 2 commits into from
Aug 10, 2022
Merged

add unit test for cli #274

merged 2 commits into from
Aug 10, 2022

Conversation

chloeyin
Copy link
Contributor

Signed-off-by: zaihaoyin [email protected]

This PR adds unit test for some cli commands, only to make sure the flags are parsed correctly.
This is the last PR of the whole series(#255).

Signed-off-by: zaihaoyin <[email protected]>
@codecov-commenter
Copy link

codecov-commenter commented Jul 29, 2022

Codecov Report

Merging #274 (eebbd39) into main (1f858d0) will decrease coverage by 20.62%.
The diff coverage is n/a.

@@             Coverage Diff             @@
##             main     #274       +/-   ##
===========================================
- Coverage   50.00%   29.37%   -20.63%     
===========================================
  Files          11       27       +16     
  Lines         344     1685     +1341     
===========================================
+ Hits          172      495      +323     
- Misses        164     1176     +1012     
- Partials        8       14        +6     
Impacted Files Coverage Δ
cmd/notation/plugin.go 0.00% <0.00%> (ø)
cmd/notation/push.go 24.61% <0.00%> (ø)
cmd/notation/manifest.go 0.00% <0.00%> (ø)
cmd/notation/logout.go 54.16% <0.00%> (ø)
cmd/notation/registry.go 0.00% <0.00%> (ø)
cmd/notation/common.go 100.00% <0.00%> (ø)
cmd/notation/verify.go 19.00% <0.00%> (ø)
cmd/notation/main.go 0.00% <0.00%> (ø)
cmd/notation/key.go 23.52% <0.00%> (ø)
cmd/notation/sign.go 29.88% <0.00%> (ø)
... and 6 more

📣 Codecov can now indicate which changes are the most critical in Pull Requests. Learn more

@JeyJeyGao
Copy link
Contributor

LGTM

cmd/notation/cache_test.go Outdated Show resolved Hide resolved
cmd/notation/cache_test.go Outdated Show resolved Hide resolved
@binbin-li
Copy link
Contributor

Left some tiny comments. Just wanna raise some questions out of scope.

  1. Looks like in this PR we focus on the main use cases, successful case and a common failed case which should cover most of cases. But users can fail a command in a lot ways (a combination of flags or args). It's kind of time-wasting to test all of them, just wanna confirm we would do the same to the new PRs. @shizhMSFT
  2. This PR tests the conversion from command input to the internal Opts object. For the business logics after it, is there a good way to test it? Maybe just run cmd.ParseFlags() like this PR does? Or move the logics to other places for easier testing?

Signed-off-by: zaihaoyin <[email protected]>
@binbin-li
Copy link
Contributor

lgtm overall

@dtzar dtzar requested a review from a team August 3, 2022 00:12
Copy link
Contributor

@shizhMSFT shizhMSFT left a comment

Choose a reason for hiding this comment

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

LGTM

@shizhMSFT
Copy link
Contributor

Left some tiny comments. Just wanna raise some questions out of scope.

  1. Looks like in this PR we focus on the main use cases, successful case and a common failed case which should cover most of cases. But users can fail a command in a lot ways (a combination of flags or args). It's kind of time-wasting to test all of them, just wanna confirm we would do the same to the new PRs. @shizhMSFT
  2. This PR tests the conversion from command input to the internal Opts object. For the business logics after it, is there a good way to test it? Maybe just run cmd.ParseFlags() like this PR does? Or move the logics to other places for easier testing?

We are still figuring out a better way to test CLI.

@shizhMSFT shizhMSFT merged commit 3ced0c9 into notaryproject:main Aug 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants