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

Added unit tests for fetcher, checker and matchers packages #185

Merged
merged 5 commits into from
Sep 11, 2022

Conversation

eisandbar
Copy link
Contributor

@eisandbar eisandbar commented Aug 1, 2022

As issue #173 is pretty broad I decided to first work on part of it.

Did slight refactoring in fetcher.go for easier testing and added tests for all possible errors in Fetch()

Checker now accepts interface of type Fetcher for easier mocking. Added tests for all possible errors in Check()

Added tests for all 3 functions in matchers.go. Tests use supportedMatchers for test cases so updating supportedMatchers should update tests.

go test -cover now shows 100% for these 3 files

preslavmihaylov
preslavmihaylov previously approved these changes Aug 6, 2022
Copy link
Owner

@preslavmihaylov preslavmihaylov left a comment

Choose a reason for hiding this comment

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

Nice, thanks for the contribution!

I've removed the "closes" tag in the description as it partially completes that issue.

@preslavmihaylov
Copy link
Owner

@eisandbar looks like there are some lint issues. Could you check em out. After that, we're good to go

@eisandbar
Copy link
Contributor Author

@eisandbar looks like there are some lint issues. Could you check em out. After that, we're good to go

Hi! I fixed the lint errors and running golangci-lint v1.48.0 on my computer shows no errors, but the lint action still fails on the same files.

@eisandbar eisandbar closed this Aug 11, 2022
@eisandbar eisandbar reopened this Aug 11, 2022
@preslavmihaylov
Copy link
Owner

@eisandbar could you rebase? The lint issue should be resolved now

Added unit tests for the 3 functions in matchers.go
Changed checker to accept interface of type Fetcher for easier mocking. Added tests for all the possible errors that could happen in Check
Refactored fetcher to use fetcher.sendRequest instead of hclient.Do for easier testing. Added tests for fetch function for all possible errors
Fixed lint issues associated with return statements
@eisandbar
Copy link
Contributor Author

@preslavmihaylov Yes, no problem

@preslavmihaylov preslavmihaylov merged commit e1a8e59 into preslavmihaylov:master Sep 11, 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.

2 participants