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

Test: Replace t.error/fatal with assert/request in [raft_test.go] #173

Merged

Conversation

MrDXY
Copy link
Contributor

@MrDXY MrDXY commented Mar 1, 2024

Refactor: Replacing t.Error/t.Fatal with assert/require

This commit tries to eliminates boilerplate code in the testing suite by replacing occurrences
of t.Error and t.Fatal with assertions from the assert and require packages.

Changes Made:

  • Replaced instances of t.Error with assert
  • Replaced instances of t.Fatal with require

Affected Files:

  • [raft_test.go]

Part of: #146

@MrDXY MrDXY mentioned this pull request Mar 1, 2024
6 tasks
@MrDXY MrDXY force-pushed the replace-test-errors-with-assert-(raft_test.go) branch 2 times, most recently from 22288ae to c5a8c0d Compare March 1, 2024 06:44
Copy link
Contributor

@pav-kv pav-kv left a comment

Choose a reason for hiding this comment

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

LGTM, with a few nits/suggestions.

Thanks a lot for this clean-up!

raft_test.go Outdated Show resolved Hide resolved
raft_test.go Outdated Show resolved Hide resolved
raft_test.go Show resolved Hide resolved
raft_test.go Show resolved Hide resolved
raft_test.go Show resolved Hide resolved
raft_test.go Outdated Show resolved Hide resolved
raft_test.go Outdated Show resolved Hide resolved
raft_test.go Outdated Show resolved Hide resolved
raft_test.go Outdated Show resolved Hide resolved
raft_test.go Show resolved Hide resolved
@MrDXY
Copy link
Contributor Author

MrDXY commented Mar 2, 2024

Thank you for your review. I must admit that I may have been a bit hasty in submitting this PR with multiple errors and inconsistencies. And I'll try to double-check everything before the next commit.

@MrDXY MrDXY force-pushed the replace-test-errors-with-assert-(raft_test.go) branch 4 times, most recently from d437e80 to ac496c5 Compare March 2, 2024 13:21
Comment on lines +430 to +433
if sm.id == campaignerID {
assert.Equal(t, StateLeader, sm.state, "preVote=%v: campaigning node %d", preVote, sm.id)
} else {
assert.Equal(t, StateFollower, sm.state, "preVote=%v: campaigning node %d, current node %d", preVote, campaignerID, sm.id)
Copy link
Member

Choose a reason for hiding this comment

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

Nice minor refactor & simplification!

raft_test.go Outdated Show resolved Hide resolved
Part of: etcd-io#146

Signed-off-by: Xinyuan Du <xinyuan.du@broadcom.cn>
@MrDXY MrDXY force-pushed the replace-test-errors-with-assert-(raft_test.go) branch from ac496c5 to 176e8a7 Compare March 4, 2024 02:26
Copy link
Member

@ahrtr ahrtr left a comment

Choose a reason for hiding this comment

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

lgtm

Thank you!

@ahrtr ahrtr merged commit dd72d44 into etcd-io:main Mar 4, 2024
10 checks passed
@MrDXY MrDXY deleted the replace-test-errors-with-assert-(raft_test.go) branch March 5, 2024 04:15
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.

3 participants