@@ -12,8 +12,6 @@ import (
1212 "testing"
1313 "time"
1414
15- "github.com/google/go-cmp/cmp"
16- "github.com/google/go-cmp/cmp/cmpopts"
1715 "github.com/stretchr/testify/require"
1816 "google.golang.org/grpc"
1917
@@ -249,20 +247,27 @@ func TestDescribeTopicConsumer(t *testing.T) {
249247
250248 requireAndCleanSubset (& consumer .Consumer .Attributes , & expectedConsumerDesc .Consumer .Attributes )
251249
252- ignoredFields := []cmp. Option {
253- cmpopts . IgnoreFields (topictypes. PartitionStats {}, "LastWriteTime" , "MaxWriteTimeLag" ),
254- cmpopts . IgnoreFields (topictypes. PartitionConsumerStats {}, "PartitionReadSessionCreateTime" , "LastReadTime" , "MaxReadTimeLag" , "MaxWriteTimeLag" ),
255- }
256- for _ , p := range consumer . Partitions {
250+ for i := range consumer . Partitions {
251+ // Fields that are checked here are dynamic and they change with time, so we need to set them to expected values
252+ // to make the comparison possible.
253+ p := & consumer . Partitions [ i ]
254+
257255 require .NotNil (t , p .PartitionStats .LastWriteTime )
258256
257+ p .PartitionStats .LastWriteTime = expectedConsumerDesc .Partitions [i ].PartitionStats .LastWriteTime
258+ p .PartitionStats .MaxWriteTimeLag = expectedConsumerDesc .Partitions [i ].PartitionStats .MaxWriteTimeLag
259+
259260 require .NotNil (t , p .PartitionConsumerStats .LastReadTime )
260261 require .NotNil (t , p .PartitionConsumerStats .MaxReadTimeLag )
261262 require .NotNil (t , p .PartitionConsumerStats .MaxWriteTimeLag )
263+
264+ p .PartitionConsumerStats .PartitionReadSessionCreateTime = expectedConsumerDesc .Partitions [i ].PartitionConsumerStats .PartitionReadSessionCreateTime
265+ p .PartitionConsumerStats .LastReadTime = expectedConsumerDesc .Partitions [i ].PartitionConsumerStats .LastReadTime
266+ p .PartitionConsumerStats .MaxReadTimeLag = expectedConsumerDesc .Partitions [i ].PartitionConsumerStats .MaxReadTimeLag
267+ p .PartitionConsumerStats .MaxWriteTimeLag = expectedConsumerDesc .Partitions [i ].PartitionConsumerStats .MaxWriteTimeLag
262268 }
263- if diff := cmp .Diff (expectedConsumerDesc , consumer , ignoredFields ... ); diff != "" {
264- t .Errorf ("Mismatch (-expected +actual):\n %s" , diff )
265- }
269+
270+ require .Equal (t , expectedConsumerDesc , consumer )
266271}
267272
268273func TestSchemeList (t * testing.T ) {
0 commit comments