Copilot commented on code in PR #1413:
URL: https://github.com/apache/pulsar-client-go/pull/1413#discussion_r2314236921


##########
pulsaradmin/pkg/admin/namespace_test.go:
##########
@@ -523,3 +523,79 @@ func TestNamespaces_Properties(t *testing.T) {
        assert.Equal(t, err, nil)
        assert.Equal(t, actualPropertiesAfterRemoveCall, map[string]string{})
 }
+
+func TestNamespaces_SetMaxTopicsPerNamespace(t *testing.T) {
+       config := &config.Config{}
+       admin, err := New(config)
+       require.NoError(t, err)
+       require.NotNil(t, admin)
+
+       tests := []struct {
+               name      string
+               namespace string
+               maxTopics int
+               errReason string
+       }{
+               {
+                       name:      "Set valid max topics per namespace",
+                       namespace: "public/default",
+                       maxTopics: 100,
+                       errReason: "",
+               },
+               {
+                       name:      "Set invalid max topics per namespace",
+                       namespace: "public/default",
+                       maxTopics: -1,
+                       errReason: "maxTopicsPerNamespace must be 0 or more",
+               },
+               {
+                       name:      "Set valid max topics per namespace: 0",
+                       namespace: "public/default",
+                       maxTopics: 0,
+                       errReason: "",
+               },
+       }
+       for _, tt := range tests {
+               t.Run(tt.name, func(t *testing.T) {
+                       namespace, _ := utils.GetNamespaceName(tt.namespace)
+                       err := 
admin.Namespaces().SetMaxTopicsPerNamespace(*namespace, tt.maxTopics)
+                       if tt.errReason == "" {
+                               assert.Equal(t, nil, err)
+
+                               err = 
admin.Namespaces().RemoveMaxTopicsPerNamespace(*namespace)
+                               assert.Equal(t, nil, err)
+                       }
+                       if err != nil {

Review Comment:
   The error assertion logic is incorrect. When `tt.errReason` is not empty, 
the test expects an error but doesn't verify that an error actually occurred. 
This could lead to a panic if `err` is nil when `tt.errReason` is set. The 
error check should be inside an `else` block or the logic should be 
restructured to properly handle both success and failure cases.
   ```suggestion
                        } else {
                                assert.NotNil(t, err)
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to