Copilot commented on code in PR #3678:
URL: https://github.com/apache/dubbo-go/pull/3678#discussion_r3804943177


##########
registry/servicediscovery/customizer/metadata_service_version_customizer_test.go:
##########
@@ -0,0 +1,97 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package customizer
+
+import (
+       "testing"
+)
+
+import (
+       "github.com/stretchr/testify/assert"
+)
+
+import (

Review Comment:
   Same issue here: multiple `import` blocks in a single Go file. Consolidating 
into one `import (...)` block (grouped via blank lines) will better align with 
standard Go formatting tools and common repository lint rules.



##########
registry/servicediscovery/customizer/protocol_ports_metadata_customizer_test.go:
##########
@@ -0,0 +1,156 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package customizer
+
+import (
+       "encoding/json"
+       "testing"
+)
+
+import (
+       "github.com/stretchr/testify/assert"
+       "github.com/stretchr/testify/require"
+)
+
+import (
+       "dubbo.apache.org/dubbo-go/v3/common"
+       "dubbo.apache.org/dubbo-go/v3/common/constant"
+       "dubbo.apache.org/dubbo-go/v3/metadata"
+       "dubbo.apache.org/dubbo-go/v3/registry"
+)

Review Comment:
   This file uses multiple separate `import` blocks. `gofmt`/linters typically 
expect a single import block (with standard/third-party/local separated by 
blank lines inside the same block). Consider merging these into one `import 
(...)` block to match Go conventions and avoid style-related CI failures.



##########
registry/servicediscovery/customizer/metadata_service_url_params_customizer_test.go:
##########
@@ -28,18 +28,64 @@ import (
 )
 
 import (
+       "dubbo.apache.org/dubbo-go/v3/common"
+       "dubbo.apache.org/dubbo-go/v3/common/constant"
        "dubbo.apache.org/dubbo-go/v3/registry"
 )
 
-func TestMetadataServiceURLParamsMetadataCustomizer(t *testing.T) {
-
+func TestMetadataServiceURLParamsMetadataCustomizerGetPriority(t *testing.T) {
        msup := &metadataServiceURLParamsMetadataCustomizer{exceptKeys: 
gxset.NewSet()}
        assert.Equal(t, 0, msup.GetPriority())
-
-       msup.Customize(createInstance())
 }
 
-func createInstance() registry.ServiceInstance {
+// TestMetadataServiceURLParamsCustomizeNilURL verifies that when the metadata
+// service URL is not exported (nil), Customize writes nothing into metadata.
+func TestMetadataServiceURLParamsCustomizeNilURL(t *testing.T) {
+       msup := &metadataServiceURLParamsMetadataCustomizer{exceptKeys: 
gxset.NewSet()}
        ins := &registry.DefaultServiceInstance{}
-       return ins
+       msup.Customize(ins)
+       _, ok := 
ins.GetMetadata()[constant.MetadataServiceURLParamsPropertyName]
+       assert.False(t, ok, "nothing should be written when the metadata 
service URL is nil")
+}

Review Comment:
   This test asserts behavior for a nil metadata-service URL, but it doesn’t 
arrange any state to ensure 
`metadata.GetMetadataService().GetMetadataServiceURL()` is actually nil at 
runtime. Because the metadata service is a global singleton (and other tests in 
the package may export it), this test can become order-dependent/flaky. To make 
it deterministic, explicitly set up/override the metadata service to return nil 
for the duration of the test (and restore it with `t.Cleanup`), or refactor the 
customizer to accept a metadata-service interface so the test can inject a stub.



-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to