Skip to content

Commit bfca5de

Browse files
authored
test: compatible with 2.11 (streamnative#901)
Signed-off-by: Zixuan Liu <[email protected]>
1 parent 9b6a9d0 commit bfca5de

17 files changed

+29
-29
lines changed

pkg/ctl/functions/test_help.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ func ResourceDir() string {
6969
}
7070

7171
func FailImmediatelyIfErrorNotNil(t *testing.T, err ...error) {
72+
t.Helper()
7273
for _, e := range err {
7374
if e != nil {
7475
t.Logf(e.Error())

pkg/ctl/namespace/message_ttl_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,5 +43,5 @@ func TestMessageTTL(t *testing.T) {
4343
setTTLArgs = []string{"set-message-ttl", "public/test-ttl-namespace", "-t", "-2"}
4444
_, execErr, _, _ = TestNamespaceCommands(setMessageTTL, setTTLArgs)
4545
assert.NotNil(t, execErr)
46-
assert.Equal(t, execErr.Error(), "code: 412 reason: Invalid value for message TTL")
46+
assert.Contains(t, execErr.Error(), "code: 412 reason: Invalid value for message TTL")
4747
}

pkg/ctl/nsisolationpolicy/broker_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@ func TestBrokerAndBrokers(t *testing.T) {
3030
brokersFailArgs := []string{"brokers", "standalone"}
3131
_, execErr, _, _ := TestNsIsolationPolicyCommands(getAllBrokersWithPolicies, brokersFailArgs)
3232
assert.NotNil(t, execErr)
33-
exceptedErr := "code: 404 reason: namespace-isolation policies not found for standalone"
34-
assert.Equal(t, exceptedErr, execErr.Error())
33+
assert.Contains(t, execErr.Error(), "code: 404 reason")
3534

3635
setPolicyArgs := []string{"set", "standalone", "test-policy-1",
3736
"--auto-failover-policy-params", "min_limit=3,usage_threshold=100",

pkg/ctl/subscription/delete_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ func TestDeleteNonExistingSub(t *testing.T) {
7777
args = []string{"delete", "test-delete-non-existing-sub-topic", "test-delete-non-existing-sub-non-existing"}
7878
_, execErr, _, _ = TestSubCommands(DeleteCmd, args)
7979
assert.NotNil(t, execErr)
80-
assert.Equal(t, "code: 404 reason: Subscription not found", execErr.Error())
80+
assert.Contains(t, execErr.Error(), "code: 404 reason: Subscription")
8181

8282
args = []string{"list", "test-delete-non-existing-sub-topic"}
8383
out, execErr, _, _ = TestSubCommands(ListCmd, args)
@@ -89,5 +89,5 @@ func TestDeleteNonExistingTopicSub(t *testing.T) {
8989
args := []string{"delete", "non-existing-topic", "non-existing-topic-sub"}
9090
_, execErr, _, _ := TestSubCommands(DeleteCmd, args)
9191
assert.NotNil(t, execErr)
92-
assert.Equal(t, "code: 404 reason: Topic not found", execErr.Error())
92+
assert.Contains(t, execErr.Error(), "code: 404 reason: Topic")
9393
}

pkg/ctl/subscription/expire_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,12 @@ func TestExpireNonExistingTopic(t *testing.T) {
5656
"test-expire-messages-non-existing-topic-sub"}
5757
_, execErr, _, _ := TestSubCommands(ExpireCmd, args)
5858
assert.NotNil(t, execErr)
59-
assert.Equal(t, "code: 404 reason: Topic not found", execErr.Error())
59+
assert.Contains(t, execErr.Error(), "code: 404 reason: Topic")
6060

6161
args = []string{"expire", "--expire-time", "1", "--all", "non-existing-topic"}
6262
_, execErr, _, _ = TestSubCommands(ExpireCmd, args)
6363
assert.NotNil(t, execErr)
64-
assert.Equal(t, "code: 404 reason: Topic not found", execErr.Error())
64+
assert.Contains(t, execErr.Error(), "code: 404 reason: Topic")
6565
}
6666

6767
func TestExpireNonExistingSub(t *testing.T) {
@@ -74,5 +74,5 @@ func TestExpireNonExistingSub(t *testing.T) {
7474
"test-expire-messages-non-existing-sub-non-existing"}
7575
_, execErr, _, _ = TestSubCommands(ExpireCmd, args)
7676
assert.NotNil(t, execErr)
77-
assert.Equal(t, "code: 404 reason: Subscription not found", execErr.Error())
77+
assert.Contains(t, execErr.Error(), "code: 404 reason: Subscription")
7878
}

pkg/ctl/subscription/list_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,5 @@ func TestListNonExistingTopicSub(t *testing.T) {
3535
args := []string{"list", "non-existing-topic"}
3636
_, execErr, _, _ := TestSubCommands(ListCmd, args)
3737
assert.NotNil(t, execErr)
38-
assert.Equal(t, "code: 404 reason: Topic not found", execErr.Error())
38+
assert.Contains(t, execErr.Error(), "code: 404 reason: Topic")
3939
}

pkg/ctl/subscription/skip_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,13 @@ func TestSkipNonExistingTopic(t *testing.T) {
5959
"test-skip-messages-non-existing-topic-sub"}
6060
_, execErr, _, _ := TestSubCommands(SkipCmd, args)
6161
assert.NotNil(t, execErr)
62-
assert.Equal(t, "code: 404 reason: Topic not found", execErr.Error())
62+
assert.Contains(t, execErr.Error(), "code: 404 reason: Topic")
6363

6464
args = []string{"skip", "--all", "test-skip-messages-non-existing-topic",
6565
"test-skip-messages-non-existing-topic-sub"}
6666
_, execErr, _, _ = TestSubCommands(SkipCmd, args)
6767
assert.NotNil(t, execErr)
68-
assert.Equal(t, "code: 404 reason: Topic not found", execErr.Error())
68+
assert.Contains(t, execErr.Error(), "code: 404 reason: Topic")
6969
}
7070

7171
func TestSkipNonExistingSub(t *testing.T) {
@@ -78,12 +78,12 @@ func TestSkipNonExistingSub(t *testing.T) {
7878
"test-skip-messages-non-existing-sub-non-existing"}
7979
_, execErr, _, _ = TestSubCommands(SkipCmd, args)
8080
assert.NotNil(t, execErr)
81-
assert.Equal(t, "code: 404 reason: Subscription not found", execErr.Error())
81+
assert.Contains(t, execErr.Error(), "code: 404 reason: Subscription")
8282

8383
args = []string{"skip", "--all", "test-skip-messages-non-existing-sub-topic",
8484
"test-skip-messages-non-existing-sub-non-existing"}
8585
_, execErr, _, _ = TestSubCommands(SkipCmd, args)
86-
assert.Equal(t, "code: 404 reason: Subscription not found", execErr.Error())
86+
assert.Contains(t, execErr.Error(), "code: 404 reason: Subscription")
8787
}
8888

8989
func TestSkipNoExistingSubCharactersEscaped(t *testing.T) {
@@ -92,5 +92,5 @@ func TestSkipNoExistingSubCharactersEscaped(t *testing.T) {
9292
args := []string{"skip", "--all", "test-skip-messages-non-existing-sub-topic",
9393
"test-skip-messages-non-existing-sub-non-existing/with/special chars"}
9494
_, execErr, _, _ := TestSubCommands(SkipCmd, args)
95-
assert.Equal(t, "code: 404 reason: Subscription not found", execErr.Error())
95+
assert.Contains(t, execErr.Error(), "code: 404 reason: Subscription")
9696
}

pkg/ctl/topic/compact_status_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ func TestCompactStatusNonExistingTopicError(t *testing.T) {
3434
args := []string{"compact-status", "test-non-existing-compact-status"}
3535
_, execErr, _, _ := TestTopicCommands(StatusCmd, args)
3636
assert.NotNil(t, execErr)
37-
assert.Equal(t, "code: 404 reason: Topic not found", execErr.Error())
37+
assert.Contains(t, execErr.Error(), "code: 404 reason: Topic")
3838
}
3939

4040
func TestCompactStatusNonPersistentTopicError(t *testing.T) {

pkg/ctl/topic/compact_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ func TestCompactNonExistingTopic(t *testing.T) {
5757
args := []string{"compact", "test-compact-non-existing-topic"}
5858
_, execErr, _, _ := TestTopicCommands(CompactCmd, args)
5959
assert.NotNil(t, execErr)
60-
assert.Equal(t, "code: 404 reason: Topic not found", execErr.Error())
60+
assert.Contains(t, execErr.Error(), "code: 404 reason: Topic")
6161
}
6262

6363
func TestCompactNonPersistentTopic(t *testing.T) {

pkg/ctl/topic/delete_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,12 @@ func TestDeleteNonExistPartitionedTopic(t *testing.T) {
7575
args := []string{"delete", "non-existent-partitioned-topic"}
7676
_, execErr, _, _ := TestTopicCommands(DeleteTopicCmd, args)
7777
assert.NotNil(t, execErr)
78-
assert.Equal(t, "code: 404 reason: Partitioned topic does not exist", execErr.Error())
78+
assert.Contains(t, execErr.Error(), "code: 404 reason: Partitioned")
7979
}
8080

8181
func TestDeleteNonExistNonPartitionedTopic(t *testing.T) {
8282
args := []string{"delete", "--non-partitioned", "non-existent-non-partitioned-topic"}
8383
_, execErr, _, _ := TestTopicCommands(DeleteTopicCmd, args)
8484
assert.NotNil(t, execErr)
85-
assert.Equal(t, "code: 404 reason: Topic not found", execErr.Error())
85+
assert.Contains(t, execErr.Error(), "code: 404 reason: Topic")
8686
}

0 commit comments

Comments
 (0)