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

Fix up some tests to do better error handling. #2011

Open
wants to merge 4 commits into
base: master
from

Conversation

@Martin2112
Copy link
Contributor

@Martin2112 Martin2112 commented Dec 17, 2019

Also log an error for a failed close in operation manager but no behavioural changes.

Checklist

Martin2112 added 4 commits Dec 10, 2019
@codecov
Copy link

@codecov codecov bot commented Dec 17, 2019

Codecov Report

Merging #2011 into master will decrease coverage by 0.05%.
The diff coverage is 33.33%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master   #2011      +/-   ##
=========================================
- Coverage   58.25%   58.2%   -0.06%     
=========================================
  Files         117     117              
  Lines        9874    9876       +2     
=========================================
- Hits         5752    5748       -4     
- Misses       3618    3623       +5     
- Partials      504     505       +1
Impacted Files Coverage Δ
log/operation_manager.go 86.17% <33.33%> (-2.67%) ⬇️

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 fcad6b6...0319966. Read the comment docs.

Copy link
Contributor

@RJPercival RJPercival left a comment

Sorry this review has been a long time coming.

@@ -456,14 +457,18 @@ func TestMasterFor(t *testing.T) {
lom := NewOperationManager(info, nil)

// Check mastership twice, to give the election threads a chance to get started and report.
lom.masterFor(testCtx, firstIDs)
if _, err := lom.masterFor(testCtx, firstIDs); err != nil && !strings.Contains(test.desc, "fail") {

This comment has been minimized.

@RJPercival

RJPercival Feb 3, 2020
Contributor

nit: Checking for "fail" in the description is a bit of a subtle way to switch test behaviour. Using a wantErr field in the test struct is the most typical way I see this done.

@@ -241,12 +241,17 @@ func TestCheckDatabaseAccessible_OK(t *testing.T) {
}
}

func setNulls(ctx context.Context, db *sql.DB, treeID int64) error {
func setNulls(ctx context.Context, t *testing.T, db *sql.DB, treeID int64) error {

This comment has been minimized.

@RJPercival

RJPercival Feb 3, 2020
Contributor

nit: Since you're making this a test helper, could simply it further by removing the error return value and just calling t.Fatal() instead.

@RJPercival RJPercival assigned Martin2112 and unassigned RJPercival Feb 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants
You can’t perform that action at this time.