[#180] node: Refactor panics in unit test #182

Merged
fyrchik merged 1 commit from aarifullin/frostfs-node:feature/180-factor_out_panics into master 2023-03-29 10:33:07 +00:00
Member
  • Replace panics in unit tests by require.NoError and t.Fatalf

Signed-off-by: Airat Arifullin a.arifullin@yadro.com

* Replace panics in unit tests by require.NoError and t.Fatalf Signed-off-by: Airat Arifullin <a.arifullin@yadro.com>
aarifullin added the
frostfs-node
refactoring
labels 2023-03-28 14:20:50 +00:00
aarifullin requested review from storage-core-committers 2023-03-28 14:21:36 +00:00
aarifullin added a new dependency 2023-03-28 14:29:25 +00:00
fyrchik reviewed 2023-03-28 16:43:33 +00:00
fyrchik left a comment
Owner

Overall LGTM, but I think we could still replace some 3-line ifs with a single require

Overall LGTM, but I think we could still replace some 3-line ifs with a single `require`
@ -157,3 +157,3 @@
}
require.FailNow(t, "handler was called with an unexpected object: %s", addr)
panic("unreachable")
return errors.New("unreachable")
Owner

IMO panic better communicate our intentions here.

IMO panic better communicate our intentions here.
aarifullin marked this conversation as resolved
@ -100,3 +101,3 @@
addr.SetObject(id)
} else {
panic("object ID is not set")
t.Fatalf("object ID is not set")
Owner

Can we remove an if then?

id, isSet := obj.ID()
require.True(t, isSet, "object ID is not set")

addr.SetObject(id)
Can we remove an if then? ``` id, isSet := obj.ID() require.True(t, isSet, "object ID is not set") addr.SetObject(id) ```
aarifullin marked this conversation as resolved
@ -27,3 +29,3 @@
log, err := cfg.Build()
if err != nil {
panic("could not prepare logger: " + err.Error())
t.Fatalf("could not prepare logger: %v", err)
Owner

require.NoError?

`require.NoError`?
aarifullin marked this conversation as resolved
aarifullin force-pushed feature/180-factor_out_panics from 4c34e924df to 7156e0b397 2023-03-28 20:12:17 +00:00 Compare
aarifullin force-pushed feature/180-factor_out_panics from 7156e0b397 to e9dc4d43ef 2023-03-28 20:14:37 +00:00 Compare
ale64bit requested changes 2023-03-29 07:15:02 +00:00
@ -120,2 +120,3 @@
var errSubTreeSend = errors.New("test error")
var (
errSubTreeSend = errors.New("test error")
Member

even if it's a test error, can we use a more meaningful message?

even if it's a test error, can we use a more meaningful message?
Author
Member

Done

Done
ale64bit marked this conversation as resolved
aarifullin requested review from storage-core-developers 2023-03-29 07:17:24 +00:00
aarifullin force-pushed feature/180-factor_out_panics from e9dc4d43ef to 6786dcf950 2023-03-29 07:35:49 +00:00 Compare
dstepanov-yadro requested changes 2023-03-29 07:49:23 +00:00
@ -120,2 +120,3 @@
var errSubTreeSend = errors.New("test error")
var (
errSubTreeSend = errors.New("Send finished with error")

In general error strings should not be capitalized. From https://github.com/golang/go/wiki/CodeReviewComments#error-strings

As far as I understand, we follow this rule.

*In general error strings should not be capitalized*. From https://github.com/golang/go/wiki/CodeReviewComments#error-strings As far as I understand, we follow this rule.
Author
Member

Yes, it's my fault. Here Send is name of the method. Just coincidence :) I'll fix it anyway

Yes, it's my fault. Here Send is name of the method. Just coincidence :) I'll fix it anyway
ale64bit approved these changes 2023-03-29 08:54:56 +00:00
ale64bit left a comment
Member

LGTM (after resolving the pending comment)

LGTM (after resolving the pending comment)
aarifullin force-pushed feature/180-factor_out_panics from 6786dcf950 to 221203beeb 2023-03-29 09:39:19 +00:00 Compare
aarifullin requested review from dstepanov-yadro 2023-03-29 09:39:39 +00:00
aarifullin requested review from ale64bit 2023-03-29 09:44:59 +00:00
ale64bit approved these changes 2023-03-29 09:58:40 +00:00
dstepanov-yadro approved these changes 2023-03-29 09:59:58 +00:00
fyrchik merged commit 221203beeb into master 2023-03-29 10:33:07 +00:00
Sign in to join this conversation.
No reviewers
TrueCloudLab/storage-core-committers
No milestone
No project
No assignees
4 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: TrueCloudLab/frostfs-node#182
No description provided.