Make unit tests use require.NoError/t.Fatalf instead panic #180

Closed
opened 2023-03-28 11:29:12 +00:00 by aarifullin · 1 comment
Collaborator

Some unit tests and test util functions throw panic if an error occured:

func testNewEngineWithShards(shards ...*shard.Shard) *StorageEngine {
	engine := New()

	for _, s := range shards {
		pool, err := ants.NewPool(10, ants.WithNonblocking(true))
		if err != nil {
			panic(err) // it's better to use require.NoError(t, err)
		}
    ...
}

The correct way to stop a test in the case of an error is to invoke require.NoError or t.Fatalf. The proposal is to replace all panic-s in unit tests by these package methods.

Some unit tests and test util functions throw `panic` if an error occured: ``` func testNewEngineWithShards(shards ...*shard.Shard) *StorageEngine { engine := New() for _, s := range shards { pool, err := ants.NewPool(10, ants.WithNonblocking(true)) if err != nil { panic(err) // it's better to use require.NoError(t, err) } ... } ``` The correct way to stop a test in the case of an error is to invoke `require.NoError` or `t.Fatalf`. The proposal is to replace all `panic`-s in unit tests by these package methods.
aarifullin added the
frostfs-node
triage
refactoring
labels 2023-03-28 11:29:12 +00:00
aarifullin self-assigned this 2023-03-28 11:29:12 +00:00
aarifullin added a new dependency 2023-03-28 14:29:25 +00:00
aarifullin removed a dependency 2023-03-28 14:29:37 +00:00

Closed via #182

Closed via #182
Sign in to join this conversation.
No Milestone
No Assignees
2 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#180
There is no content yet.