From b2403c54734e257830f0f9bf6b7c697fa8e7f0af Mon Sep 17 00:00:00 2001 From: Xinyuan Du Date: Mon, 1 Apr 2024 11:52:54 +0800 Subject: [PATCH] replace t.error/fatal with assert/request (/tracker/inflights_test.go) Signed-off-by: Xinyuan Du --- tracker/inflights_test.go | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/tracker/inflights_test.go b/tracker/inflights_test.go index a7b1c7f5..100f74da 100644 --- a/tracker/inflights_test.go +++ b/tracker/inflights_test.go @@ -17,6 +17,7 @@ package tracker import ( "testing" + "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -203,14 +204,10 @@ func TestInflightsFull(t *testing.T) { addUntilFull := func(begin, end int) { for i := begin; i < end; i++ { - if in.Full() { - t.Fatalf("full at %d, want %d", i, end) - } + require.False(t, in.Full(), "full at %d, want %d", i, end) in.Add(uint64(i), uint64(100+i)) } - if !in.Full() { - t.Fatalf("not full at %d", end) - } + require.True(t, in.Full(), "not full at %d", end) } addUntilFull(0, tc.fullAt) @@ -218,9 +215,7 @@ func TestInflightsFull(t *testing.T) { addUntilFull(tc.fullAt, tc.againAt) defer func() { - if r := recover(); r == nil { - t.Errorf("Add() did not panic") - } + assert.NotEmpty(t, recover(), "Add() did not panic") }() in.Add(100, 1024) })