Fix up some tests to do better error handling. #2011
Conversation
Codecov Report
@@ 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
Continue to review full report at Codecov.
|
|
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") { | |||
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.
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 { | |||
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.
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.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Also log an error for a failed close in operation manager but no behavioural changes.
Checklist