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

Move error_test.go to a separate test package #5796

Merged
merged 6 commits into from
Apr 8, 2024

Conversation

jakobht
Copy link
Member

@jakobht jakobht commented Mar 19, 2024

What changed?
Moved error_test.go to a separate test package

Why?
The folder testdata is ignored when running tests, so moving this test to a test package that isn't ignored

How did you test it?
Made sure the test runs when doing go test and make test

Potential risks

Release notes

Documentation Changes

Copy link

codecov bot commented Mar 19, 2024

Codecov Report

Merging #5796 (3bab95f) into master (9024217) will not change coverage.
The diff coverage is n/a.

Additional details and impacted files

see 4 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

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

@@ -20,17 +20,18 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.

package testdata
package testdata_test
Copy link
Member

Choose a reason for hiding this comment

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

FYI currently the coverage numbers we collect only include the tests targeting the code in the same package. So a separate package with unit tests don't add to coverage numbers. There are workarounds for this setup but it increases total test time.
Looks like this file is only covering functionality of some stuff in testdata which is not part of actual code so maybe we can leave this there

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh, that's sad, I was not aware.
Go has some magic folder names (e.g. starting with _ and testdata) for which it does not run tests at all, so that's why I moved it out. So now the test is acctually run by the CI (before it was not).

Copy link
Member

Choose a reason for hiding this comment

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

@taylanisikdemir I'd broadcast this to the team, I wasn't aware either and this convention is pretty common

Copy link
Member Author

@jakobht jakobht Mar 20, 2024

Choose a reason for hiding this comment

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

I agree, just still note that in this PR, we have to move it out as tests in folders called testdata are never picked up by go test.
Another option is to rename the testdata folder, but then we have to write tests for all the files in testdata, currently these files are (hopefully) not counted in the coverage numbers.

Copy link
Member

Choose a reason for hiding this comment

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

Stuff in testdata should only be used by other tests and shouldn't require to be tested. If this functionality deserves its own tests then let's move it to some other folder or add those tests to one of the relevant _test.go file. No need to track coverage for this.

Copy link
Member Author

Choose a reason for hiding this comment

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

Moved to the testing package

@coveralls
Copy link

coveralls commented Apr 5, 2024

Pull Request Test Coverage Report for Build 018ebc69-3ae6-44df-a367-9b0fc40d6c69

Details

  • 2 of 2 (100.0%) changed or added relevant lines in 1 file are covered.
  • 82 unchanged lines in 19 files lost coverage.
  • Overall coverage decreased (-0.08%) to 67.205%

Files with Coverage Reduction New Missed Lines %
common/task/weighted_round_robin_task_scheduler.go 2 89.05%
common/persistence/sql/sqlplugin/postgres/task.go 2 73.4%
common/persistence/sql/sqlplugin/postgres/db.go 2 80.0%
common/persistence/execution_manager.go 2 83.54%
common/persistence/sql/sqlplugin/mysql/task.go 2 73.68%
service/matching/db.go 2 73.23%
service/history/task/transfer_active_task_executor.go 2 72.7%
common/persistence/statsComputer.go 2 96.07%
common/persistence/sql/sqlplugin/mysql/db.go 2 79.49%
common/persistence/historyManager.go 2 66.67%
Totals Coverage Status
Change from base Build 018eb4d2-dd06-4921-a558-dd33d923e1a6: -0.08%
Covered Lines: 97985
Relevant Lines: 145801

💛 - Coveralls

@@ -0,0 +1,40 @@
// The MIT License (MIT)
Copy link
Member

Choose a reason for hiding this comment

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

We have been renaming files to snake_case as we touch them

@jakobht jakobht merged commit 88a4dea into cadence-workflow:master Apr 8, 2024
20 checks passed
@jakobht jakobht deleted the moveErrorTest branch April 8, 2024 06:59
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.

4 participants