Skip to content

Commit b8e64eb

Browse files
committed
Fix tests
1 parent 98aebc2 commit b8e64eb

File tree

1 file changed

+26
-2
lines changed

1 file changed

+26
-2
lines changed

pkg/ctl/topic/stats_test.go

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,15 @@ func TestGetPerPartitionedStatsCmd(t *testing.T) {
128128
t.Fatal(err)
129129
}
130130

131+
assert.Greater(t, stats.TopicCreationTimeStamp, int64(0))
132+
stats.TopicCreationTimeStamp = 0
133+
partitionKey := "persistent://public/default/test-topic-per-partitioned-stats-partition-0"
134+
assert.Contains(t, stats.Partitions, partitionKey)
135+
assert.Greaterf(t, stats.Partitions[partitionKey].TopicCreationTimeStamp, int64(0), "TopicCreationTimeStamp should be greater than 0")
136+
v := stats.Partitions[partitionKey]
137+
v.TopicCreationTimeStamp = 0
138+
stats.Partitions[partitionKey] = v
139+
131140
defaultStats := utils.PartitionedTopicStats{
132141
MsgRateIn: 0,
133142
MsgRateOut: 0,
@@ -141,7 +150,7 @@ func TestGetPerPartitionedStatsCmd(t *testing.T) {
141150
DeDuplicationStatus: "",
142151
Metadata: utils.PartitionedTopicMetadata{Partitions: 1},
143152
Partitions: map[string]utils.TopicStats{
144-
"persistent://public/default/test-topic-per-partitioned-stats-partition-0": {
153+
partitionKey: {
145154
MsgRateIn: 0,
146155
MsgRateOut: 0,
147156
MsgThroughputIn: 0,
@@ -216,6 +225,8 @@ func TestGetStatsWithoutSubscriptionBacklogSize(t *testing.T) {
216225
if err != nil {
217226
t.Fatal(err)
218227
}
228+
assert.Greaterf(t, stats.TopicCreationTimeStamp, int64(0), "TopicCreationTimeStamp should be greater than 0")
229+
stats.TopicCreationTimeStamp = 0
219230

220231
assert.Equal(t, defaultStats, stats)
221232
}
@@ -234,6 +245,8 @@ func TestGetStatsWithEarliestTimeInBacklog(t *testing.T) {
234245
if err != nil {
235246
t.Fatal(err)
236247
}
248+
assert.Greaterf(t, stats.TopicCreationTimeStamp, int64(0), "TopicCreationTimeStamp should be greater than 0")
249+
stats.TopicCreationTimeStamp = 0
237250

238251
assert.Equal(t, defaultStats, stats)
239252
}
@@ -252,6 +265,8 @@ func TestGetStatsWithMultipleNewFlags(t *testing.T) {
252265
if err != nil {
253266
t.Fatal(err)
254267
}
268+
assert.Greaterf(t, stats.TopicCreationTimeStamp, int64(0), "TopicCreationTimeStamp should be greater than 0")
269+
stats.TopicCreationTimeStamp = 0
255270

256271
assert.Equal(t, defaultStats, stats)
257272
}
@@ -300,6 +315,15 @@ func TestGetPerPartitionStatsWithNewFlags(t *testing.T) {
300315
t.Fatal(err)
301316
}
302317

318+
assert.Greater(t, stats.TopicCreationTimeStamp, int64(0))
319+
stats.TopicCreationTimeStamp = 0
320+
partitionKey := "persistent://public/default/test-per-part-stats-new-flags-partition-0"
321+
assert.Contains(t, stats.Partitions, partitionKey)
322+
assert.Greaterf(t, stats.Partitions[partitionKey].TopicCreationTimeStamp, int64(0), "TopicCreationTimeStamp should be greater than 0")
323+
v := stats.Partitions[partitionKey]
324+
v.TopicCreationTimeStamp = 0
325+
stats.Partitions[partitionKey] = v
326+
303327
defaultStats := utils.PartitionedTopicStats{
304328
MsgRateIn: 0,
305329
MsgRateOut: 0,
@@ -313,7 +337,7 @@ func TestGetPerPartitionStatsWithNewFlags(t *testing.T) {
313337
DeDuplicationStatus: "",
314338
Metadata: utils.PartitionedTopicMetadata{Partitions: 1},
315339
Partitions: map[string]utils.TopicStats{
316-
"persistent://public/default/test-per-part-stats-new-flags-partition-0": {
340+
partitionKey: {
317341
MsgRateIn: 0,
318342
MsgRateOut: 0,
319343
MsgThroughputIn: 0,

0 commit comments

Comments
 (0)