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

test: pkg/aws #30

Merged
merged 2 commits into from
Dec 5, 2023
Merged

test: pkg/aws #30

merged 2 commits into from
Dec 5, 2023

Conversation

skl
Copy link
Contributor

@skl skl commented Dec 5, 2023

Refactored dependency on *prometheus.Registry struct to provider.Registry interface to support mocking.

New still needs work but this PR introduces gomock as necessary to create compatible mocks in this package, mockery-generated mocks were not type-compatible for some reason.

Note that this means there are duplicate mocks generated for the new interface.

79% coverage.

@skl skl requested review from Pokom and the-it December 5, 2023 15:03
@skl skl self-assigned this Dec 5, 2023
@skl
Copy link
Contributor Author

skl commented Dec 5, 2023

As suspected, this error has come back due to the hard dependency on AWS:

=== RUN   Test_New
=== RUN   Test_New/no_error
    aws_test.go:29: 
        	Error Trace:	/home/runner/work/cloudcost-exporter/cloudcost-exporter/pkg/aws/aws_test.go:29
        	Error:      	Received unexpected error:
        	            	operation error ec2imds: GetRegion, failed to get API token, operation error ec2imds: getToken, http response error StatusCode: 400, request to EC2 IMDS failed
        	Test:       	Test_New/no_error
--- FAIL: Test_New (0.00s)
    --- FAIL: Test_New/no_error (0.00s)

I'll skip the test for now (coverage dropped to 34.5%), that refactor is probably worth a separate PR.

Copy link
Contributor

@Pokom Pokom left a comment

Choose a reason for hiding this comment

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

🚀 Checked out locally and ran everything, all the exporters are still working as expected. Curious to see what the refactor will look like to improve coverage!

@skl skl merged commit 318d97b into main Dec 5, 2023
1 check passed
@skl skl deleted the skl/test-pkg-aws branch December 5, 2023 16:38
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.

2 participants