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

chore(tests): add unit tests for cmd/template.go, cmd/util.go and cmd/version.go #765

Merged
merged 10 commits into from
Jul 2, 2024

Conversation

Mangaal
Copy link
Contributor

@Mangaal Mangaal commented Jul 2, 2024

This PR adds unit tests for cmd/template.go, cmd/util.go and cmd/version.go.

Changes Made

  • Replaced log.Fatalf with fmt.Fprintf for printing errors to cmd.ErrOrStderr().
  • Replaced fmt.Printf with fmt.Fprintf for printing output to cmd.OutOrStdout().

Reason for Changes

The previous implementation used log.Fatalf and fmt.Printf, which made it difficult to capture the command output in unit tests. By using fmt.Fprintf with cmd.ErrOrStderr() and cmd.OutOrStdout(), the output can be directed to buffers, allowing the unit test to capture and verify the output effectively.

@codecov-commenter
Copy link

codecov-commenter commented Jul 2, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 61.82%. Comparing base (80f6c96) to head (d5804df).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #765      +/-   ##
==========================================
+ Coverage   59.98%   61.82%   +1.83%     
==========================================
  Files          31       31              
  Lines        3109     3112       +3     
==========================================
+ Hits         1865     1924      +59     
+ Misses       1100     1044      -56     
  Partials      144      144              

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

Copy link
Contributor

@jannfis jannfis left a comment

Choose a reason for hiding this comment

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

Nice, thank you!
LGTM.

@jannfis jannfis changed the title add unit tests for cmd/template.go, cmd/util.go and cmd/version.go chore(tests): add unit tests for cmd/template.go, cmd/util.go and cmd/version.go Jul 2, 2024
@jannfis jannfis merged commit 9684b34 into argoproj-labs:master Jul 2, 2024
10 checks passed
sribiere-jellysmack pushed a commit to sribiere-jellysmack/argocd-image-updater that referenced this pull request Aug 13, 2024
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.

3 participants