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: Add testpackage linter #156

Merged
merged 4 commits into from
Feb 4, 2022
Merged

chore: Add testpackage linter #156

merged 4 commits into from
Feb 4, 2022

Conversation

kylecarbs
Copy link
Member

Enforces a consistent test package layout.
This makes it difficult to test internal
functionality, which I believe promotes
healthy decomposition, and minimal package
exports.

Enforces a consistent test package layout.
This makes it difficult to test internal
functionality, which I believe promotes
healthy decomposition, and minimal package
exports.
@kylecarbs kylecarbs self-assigned this Feb 3, 2022
@codecov
Copy link

codecov bot commented Feb 3, 2022

Codecov Report

Merging #156 (4afc5a3) into main (b6d27ad) will increase coverage by 0.37%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #156      +/-   ##
==========================================
+ Coverage   66.62%   66.99%   +0.37%     
==========================================
  Files         103      103              
  Lines        5129     5129              
  Branches       68       68              
==========================================
+ Hits         3417     3436      +19     
+ Misses       1396     1380      -16     
+ Partials      316      313       -3     
Flag Coverage Δ
unittest-go-macos-latest 63.96% <ø> (+0.07%) ⬆️
unittest-go-ubuntu-latest 65.71% <ø> (-0.16%) ⬇️
unittest-go-windows-latest 63.71% <ø> (+0.04%) ⬆️
unittest-js 64.21% <ø> (ø)
Impacted Files Coverage Δ
provisionerd/provisionerd.go 68.94% <0.00%> (-0.74%) ⬇️
peerbroker/listen.go 84.80% <0.00%> (+2.39%) ⬆️
peer/channel.go 87.19% <0.00%> (+2.43%) ⬆️
peer/conn.go 79.48% <0.00%> (+2.82%) ⬆️
peerbroker/dial.go 80.95% <0.00%> (+4.76%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b6d27ad...4afc5a3. Read the comment docs.

Copy link
Contributor

@bryphe-coder bryphe-coder left a comment

Choose a reason for hiding this comment

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

This makes it difficult to test internal functionality, which I believe promotes healthy decomposition

Agree 100%! LGTM, thanks for bringing this in

@@ -1,6 +1,6 @@
//go:build linux

package terraform
package terraform_test
Copy link
Contributor

Choose a reason for hiding this comment

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

I generally like this approach, since it means the tests are done against the externally-visible functions. Sometimes I personally have tests where I want to poke at the internals, and I'm never sure if I should be exporting those functions (e.g. a package that provides an exported func A, which invokes some small internal helpers B and C; I like to have tests for all of them, in which case I'd have both a _test and non-_test package)

I see that this tool skips packages named XXX_internal_test.go by convention, which makes things clearer even in the case where we want to look at the internals.

Nice change! 👍

Copy link
Member Author

Choose a reason for hiding this comment

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

I love enforcing these conventions. Consistency is key!

@kylecarbs kylecarbs merged commit 75468fa into main Feb 4, 2022
@kylecarbs kylecarbs deleted the testpackage branch February 4, 2022 18:06
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.

None yet

3 participants