From 61b05fad9500ee54908fe33d9185cc28bee5ba63 Mon Sep 17 00:00:00 2001 From: chrislu Date: Mon, 11 Dec 2023 20:57:29 -0800 Subject: [PATCH] fix test --- weed/mq/pub_balancer/allocate_test.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/weed/mq/pub_balancer/allocate_test.go b/weed/mq/pub_balancer/allocate_test.go index 298b9ebc1..a9056cdb9 100644 --- a/weed/mq/pub_balancer/allocate_test.go +++ b/weed/mq/pub_balancer/allocate_test.go @@ -3,7 +3,7 @@ package pub_balancer import ( cmap "github.com/orcaman/concurrent-map/v2" "github.com/seaweedfs/seaweedfs/weed/pb/mq_pb" - "reflect" + "github.com/stretchr/testify/assert" "testing" ) @@ -53,8 +53,14 @@ func testThem(t *testing.T, tests []struct { }) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - if gotAssignments := allocateTopicPartitions(tt.args.brokers, tt.args.partitionCount); !reflect.DeepEqual(gotAssignments, tt.wantAssignments) { - t.Errorf("allocateTopicPartitions() = %v, want %v", gotAssignments, tt.wantAssignments) + gotAssignments := allocateTopicPartitions(tt.args.brokers, tt.args.partitionCount) + assert.Equal(t, len(tt.wantAssignments), len(gotAssignments)) + for i, gotAssignment := range gotAssignments { + assert.Equal(t, tt.wantAssignments[i].LeaderBroker, gotAssignment.LeaderBroker) + assert.Equal(t, tt.wantAssignments[i].Partition.RangeStart, gotAssignment.Partition.RangeStart) + assert.Equal(t, tt.wantAssignments[i].Partition.RangeStop, gotAssignment.Partition.RangeStop) + assert.Equal(t, tt.wantAssignments[i].Partition.RingSize, gotAssignment.Partition.RingSize) + assert.Equal(t, tt.wantAssignments[i].Partition.UnixTimeNs, gotAssignment.Partition.UnixTimeNs) } }) }