Skip to content

Commit af0f57e

Browse files
authored
test: tolerate namespace not found errors (#2021)
1 parent c0ac0c7 commit af0f57e

18 files changed

Lines changed: 47 additions & 31 deletions

pkg/ctl/namespace/clear_backlog_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,10 @@ func TestClearBacklogOnNonExistingNs(t *testing.T) {
7272
args := []string{"clear-backlog", "-f", "--bundle", "0xc0000000_0xffffffff", ns}
7373
_, execErr, _, _ := TestNamespaceCommands(ClearBacklogCmd, args)
7474
assert.NotNil(t, execErr)
75-
assert.Equal(t, "code: 404 reason: Namespace does not exist", execErr.Error())
75+
assertNamespaceNotExistError(t, execErr)
7676

7777
args = []string{"clear-backlog", "-f", "--sub", "sub", "--bundle", "0xc0000000_0xffffffff", ns}
7878
_, execErr, _, _ = TestNamespaceCommands(ClearBacklogCmd, args)
7979
assert.NotNil(t, execErr)
80-
assert.Equal(t, "code: 404 reason: Namespace does not exist", execErr.Error())
80+
assertNamespaceNotExistError(t, execErr)
8181
}

pkg/ctl/namespace/compaction_threshold_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,13 @@ func TestSetCompactionThresholdOnNonExistingNs(t *testing.T) {
5858
args := []string{"set-compaction-threshold", "--size", "10m", ns}
5959
_, execErr, _, _ := TestNamespaceCommands(SetCompactionThresholdCmd, args)
6060
assert.NotNil(t, execErr)
61-
assert.Equal(t, "code: 404 reason: Namespace does not exist", execErr.Error())
61+
assertNamespaceNotExistError(t, execErr)
6262
}
6363

6464
func TestGetCompactionThresholdOnNonExistingNs(t *testing.T) {
6565
ns := "public/non-existing-namespace"
6666
args := []string{"get-compaction-threshold", ns}
6767
_, execErr, _, _ := TestNamespaceCommands(GetCompactionThresholdCmd, args)
6868
assert.NotNil(t, execErr)
69-
assert.Equal(t, "code: 404 reason: Namespace does not exist", execErr.Error())
69+
assertNamespaceNotExistError(t, execErr)
7070
}

pkg/ctl/namespace/dispatch_rate_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,5 +112,5 @@ func TestGetDispatchRateOnNonExistingNs(t *testing.T) {
112112
args := []string{"get-dispatch-rate", ns}
113113
_, execErr, _, _ := TestNamespaceCommands(GetDispatchRateCmd, args)
114114
assert.NotNil(t, execErr)
115-
assert.Equal(t, "code: 404 reason: Namespace does not exist", execErr.Error())
115+
assertNamespaceNotExistError(t, execErr)
116116
}

pkg/ctl/namespace/max_consumers_per_subscription_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ func TestSetMaxConsumersPerSubscriptionOnNonExistingTopic(t *testing.T) {
5757
args := []string{"set-max-consumers-per-subscription", "--size", "10", ns}
5858
_, execErr, _, _ := TestNamespaceCommands(SetMaxConsumersPerSubscriptionCmd, args)
5959
assert.NotNil(t, execErr)
60-
assert.Equal(t, "code: 404 reason: Namespace does not exist", execErr.Error())
60+
assertNamespaceNotExistError(t, execErr)
6161
}
6262

6363
func TestSetMaxConsumersPerSubscriptionWithInvalidSize(t *testing.T) {
@@ -72,5 +72,5 @@ func TestGetMaxConsumersPerSubscriptionOnNonExistingTopic(t *testing.T) {
7272
args := []string{"get-max-consumers-per-subscription", ns}
7373
_, execErr, _, _ := TestNamespaceCommands(GetMaxConsumersPerSubscriptionCmd, args)
7474
assert.NotNil(t, execErr)
75-
assert.Equal(t, "code: 404 reason: Namespace does not exist", execErr.Error())
75+
assertNamespaceNotExistError(t, execErr)
7676
}

pkg/ctl/namespace/max_consumers_per_topic_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ func TestSetMaxConsumersPerTopicOnNonExistingTopic(t *testing.T) {
5757
args := []string{"set-max-consumers-per-topic", "--size", "10", ns}
5858
_, execErr, _, _ := TestNamespaceCommands(SetMaxConsumersPerTopicCmd, args)
5959
assert.NotNil(t, execErr)
60-
assert.Equal(t, "code: 404 reason: Namespace does not exist", execErr.Error())
60+
assertNamespaceNotExistError(t, execErr)
6161
}
6262

6363
func TestSetMaxConsumersPerTopicWithInvalidSize(t *testing.T) {
@@ -72,5 +72,5 @@ func TestGetMaxConsumersPerTopicOnNonExistingTopic(t *testing.T) {
7272
args := []string{"get-max-consumers-per-topic", ns}
7373
_, execErr, _, _ := TestNamespaceCommands(GetMaxConsumersPerTopicCmd, args)
7474
assert.NotNil(t, execErr)
75-
assert.Equal(t, "code: 404 reason: Namespace does not exist", execErr.Error())
75+
assertNamespaceNotExistError(t, execErr)
7676
}

pkg/ctl/namespace/max_producers_per_topic_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ func TestSetMaxProducersPerTopicOnNonExistingTopic(t *testing.T) {
5757
args := []string{"set-max-producers-per-topic", "--size", "10", ns}
5858
_, execErr, _, _ := TestNamespaceCommands(SetMaxProducersPerTopicCmd, args)
5959
assert.NotNil(t, execErr)
60-
assert.Equal(t, "code: 404 reason: Namespace does not exist", execErr.Error())
60+
assertNamespaceNotExistError(t, execErr)
6161
}
6262

6363
func TestSetMaxProducersPerTopicWithInvalidSize(t *testing.T) {
@@ -72,5 +72,5 @@ func TestGetMaxProducersPerTopicOnNonExistingTopic(t *testing.T) {
7272
args := []string{"get-max-producers-per-topic", ns}
7373
_, execErr, _, _ := TestNamespaceCommands(GetMaxProducersPerTopicCmd, args)
7474
assert.NotNil(t, execErr)
75-
assert.Equal(t, "code: 404 reason: Namespace does not exist", execErr.Error())
75+
assertNamespaceNotExistError(t, execErr)
7676
}

pkg/ctl/namespace/offload_deletion_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,21 +72,21 @@ func TestOffloadDeletionLagOnNonExistingNs(t *testing.T) {
7272
args := []string{"set-offload-deletion-lag", "--lag", "10m", ns}
7373
_, execErr, _, _ := TestNamespaceCommands(SetOffloadDeletionLagCmd, args)
7474
assert.NotNil(t, execErr)
75-
assert.Equal(t, "code: 404 reason: Namespace does not exist", execErr.Error())
75+
assertNamespaceNotExistError(t, execErr)
7676
}
7777

7878
func TestGetOfloadThresholdOnNonExistingNs(t *testing.T) {
7979
ns := "public/non-existing-namespace"
8080
args := []string{"get-offload-deletion-lag", ns}
8181
_, execErr, _, _ := TestNamespaceCommands(GetOffloadDeletionLagCmd, args)
8282
assert.NotNil(t, execErr)
83-
assert.Equal(t, "code: 404 reason: Namespace does not exist", execErr.Error())
83+
assertNamespaceNotExistError(t, execErr)
8484
}
8585

8686
func TestClearOffloadDeletionLagOnNonExistingNs(t *testing.T) {
8787
ns := "public/non-existing-namespace"
8888
args := []string{"clear-offload-deletion-lag", ns}
8989
_, execErr, _, _ := TestNamespaceCommands(ClearOffloadDeletionLagCmd, args)
9090
assert.NotNil(t, execErr)
91-
assert.Equal(t, "code: 404 reason: Namespace does not exist", execErr.Error())
91+
assertNamespaceNotExistError(t, execErr)
9292
}

pkg/ctl/namespace/offload_threshold_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,13 @@ func TestSetOffloadThresholdOnNonExistingNs(t *testing.T) {
5757
args := []string{"set-offload-threshold", "--size", "10m", ns}
5858
_, execErr, _, _ := TestNamespaceCommands(SetOffloadThresholdCmd, args)
5959
assert.NotNil(t, execErr)
60-
assert.Equal(t, "code: 404 reason: Namespace does not exist", execErr.Error())
60+
assertNamespaceNotExistError(t, execErr)
6161
}
6262

6363
func TestGetOffloadThresholdOnNonExistingNs(t *testing.T) {
6464
ns := "public/non-existing-namespace"
6565
args := []string{"get-offload-threshold", ns}
6666
_, execErr, _, _ := TestNamespaceCommands(GetOffloadThresholdCmd, args)
6767
assert.NotNil(t, execErr)
68-
assert.Equal(t, "code: 404 reason: Namespace does not exist", execErr.Error())
68+
assertNamespaceNotExistError(t, execErr)
6969
}

pkg/ctl/namespace/policies_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,12 @@ func TestPolicesNonExistTenant(t *testing.T) {
6262
args := []string{"policies", "non-existent-tenant/default"}
6363
_, execErr, _, _ := TestNamespaceCommands(getPolicies, args)
6464
assert.NotNil(t, execErr)
65-
assert.Equal(t, "code: 404 reason: Namespace does not exist", execErr.Error())
65+
assertNamespaceNotExistError(t, execErr)
6666
}
6767

6868
func TestPolicesNonExistNs(t *testing.T) {
6969
args := []string{"policies", "public/test-not-exist-ns"}
7070
_, execErr, _, _ := TestNamespaceCommands(getPolicies, args)
7171
assert.NotNil(t, execErr)
72-
assert.Equal(t, "code: 404 reason: Namespace does not exist", execErr.Error())
72+
assertNamespaceNotExistError(t, execErr)
7373
}

pkg/ctl/namespace/publish_rate_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,5 +102,5 @@ func TestGetPublishRateOnNonExistingNs(t *testing.T) {
102102
args := []string{"get-publish-rate", ns}
103103
_, execErr, _, _ := TestNamespaceCommands(GetPublishRateCmd, args)
104104
assert.NotNil(t, execErr)
105-
assert.Equal(t, "code: 404 reason: Namespace does not exist", execErr.Error())
105+
assertNamespaceNotExistError(t, execErr)
106106
}

0 commit comments

Comments
 (0)