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

refactor: prepare for e2e tests #870

Merged
merged 2 commits into from
Sep 16, 2024
Merged

refactor: prepare for e2e tests #870

merged 2 commits into from
Sep 16, 2024

Conversation

phm07
Copy link
Contributor

@phm07 phm07 commented Sep 12, 2024

This PR adds refactors that are necessary for the e2e tests.
Changes:

  • Subcommand initialization has been moved to internal/cli/root.go
  • output.Tables now accept writers as output. This is needed to catch command output. If we only catch stdout we can only run one command at once or there will be interference.

@phm07 phm07 added the refactor label Sep 12, 2024
@phm07 phm07 self-assigned this Sep 12, 2024
@phm07 phm07 requested a review from a team as a code owner September 12, 2024 10:57
Copy link

codecov bot commented Sep 12, 2024

Codecov Report

Attention: Patch coverage is 90.55118% with 12 lines in your changes missing coverage. Please review.

Project coverage is 66.95%. Comparing base (7495b14) to head (f367df7).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
internal/cmd/base/list.go 90.90% 1 Missing and 1 partial ⚠️
internal/cmd/loadbalancer/metrics.go 0.00% 2 Missing ⚠️
internal/cmd/server/metrics.go 0.00% 2 Missing ⚠️
internal/cmd/server/reset_password.go 0.00% 2 Missing ⚠️
internal/cmd/all/list.go 75.00% 1 Missing ⚠️
internal/cmd/base/describe.go 88.88% 1 Missing ⚠️
internal/cmd/config/list.go 66.66% 1 Missing ⚠️
internal/cmd/server/request_console.go 50.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #870      +/-   ##
==========================================
+ Coverage   61.46%   66.95%   +5.49%     
==========================================
  Files         238      240       +2     
  Lines        8548     8656     +108     
==========================================
+ Hits         5254     5796     +542     
+ Misses       2582     2147     -435     
- Partials      712      713       +1     

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

Comment on lines +16 to +18
// Make sure we don't have any environment variables set that could interfere with the test
t.Setenv("HCLOUD_TOKEN", "")
t.Setenv("HCLOUD_CONTEXT", "")
Copy link
Member

Choose a reason for hiding this comment

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

To be on the safe side we could get the env for all variables with prefix HCLOUD_ and unset them.

Unfortunately Go has no os.GetEnvMap(), and os.Environ() returns []string with KEY=VALUE pairs, so lots of additional effort to parse it and I am not sure its worth it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ideally you would want a "fresh" env anyway but I don't think there is a way to do that in Go

@phm07 phm07 merged commit 7643fa2 into main Sep 16, 2024
5 checks passed
@phm07 phm07 deleted the e2e-test-preparation branch September 16, 2024 11:30
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