Skip to content

Commit

Permalink
Fix table test
Browse files Browse the repository at this point in the history
  • Loading branch information
mkuratczyk committed Oct 11, 2023
1 parent ec8473c commit 043f89d
Showing 1 changed file with 28 additions and 26 deletions.
54 changes: 28 additions & 26 deletions cmd/cmd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,36 +31,38 @@ func TestPublishConsume(t *testing.T) {
}

for _, tc := range tests {
var publishProtoLabel, consumeProtoLabel string
if tc.publish == "amqp" {
publishProtoLabel = "amqp-1.0"
} else {
publishProtoLabel = tc.publish
}
if tc.consume == "amqp" {
consumeProtoLabel = "amqp-1.0"
} else {
consumeProtoLabel = tc.consume
}
rootCmd := RootCmd()
t.Run(tc.publish + "-" + tc.consume, func(t *testing.T) {
var publishProtoLabel, consumeProtoLabel string
if tc.publish == "amqp" {
publishProtoLabel = "amqp-1.0"
} else {
publishProtoLabel = tc.publish
}
if tc.consume == "amqp" {
consumeProtoLabel = "amqp-1.0"
} else {
consumeProtoLabel = tc.consume
}
rootCmd := RootCmd()

topic := "/topic/" + tc.publish + tc.consume
args := []string{tc.publish + "-" + tc.consume, "-C", "1", "-D", "1", "-t", topic, "-T", topic}
rootCmd.SetArgs(args)
fmt.Println("Running test: omq", strings.Join(args, " "))
publishedBefore := testutil.ToFloat64(metrics.MessagesPublished.WithLabelValues(publishProtoLabel))
consumedBefore := testutil.ToFloat64(metrics.MessagesConsumed.WithLabelValues(consumeProtoLabel))
topic := "/topic/" + tc.publish + tc.consume
args := []string{tc.publish + "-" + tc.consume, "-C", "1", "-D", "1", "-t", topic, "-T", topic}
rootCmd.SetArgs(args)
fmt.Println("Running test: omq", strings.Join(args, " "))
publishedBefore := testutil.ToFloat64(metrics.MessagesPublished.WithLabelValues(publishProtoLabel))
consumedBefore := testutil.ToFloat64(metrics.MessagesConsumed.WithLabelValues(consumeProtoLabel))

err := rootCmd.Execute()
err := rootCmd.Execute()

assert.Nil(t, err)
assert.Eventually(t, func() bool {
return testutil.ToFloat64(metrics.MessagesPublished.WithLabelValues(publishProtoLabel)) == publishedBefore+1
assert.Nil(t, err)
assert.Eventually(t, func() bool {
return testutil.ToFloat64(metrics.MessagesPublished.WithLabelValues(publishProtoLabel)) == publishedBefore+1

}, 2*time.Second, 100*time.Millisecond)
assert.Eventually(t, func() bool {
return testutil.ToFloat64(metrics.MessagesConsumed.WithLabelValues(consumeProtoLabel)) == consumedBefore+1
}, 2*time.Second, 100*time.Millisecond)
}, 2*time.Second, 100*time.Millisecond)
assert.Eventually(t, func() bool {
return testutil.ToFloat64(metrics.MessagesConsumed.WithLabelValues(consumeProtoLabel)) == consumedBefore+1
}, 2*time.Second, 100*time.Millisecond)
})
}
}

Expand Down

0 comments on commit 043f89d

Please sign in to comment.