nic-chen commented on code in PR #2766:
URL: https://github.com/apache/apisix-dashboard/pull/2766#discussion_r1136813879


##########
api/internal/core/entity/format_test.go:
##########
@@ -56,6 +56,39 @@ func TestNodesFormat(t *testing.T) {
        assert.Contains(t, jsonStr, `"priority":10`)
 }
 
+func TestNodesFormat_ipv6(t *testing.T) {
+       // route data saved in ETCD
+       routeStr := `{
+               "uris": ["/*"],
+               "upstream": {
+                       "type": "roundrobin",
+                       "nodes": [{
+                               "host": "::1",
+                               "port": 80,
+                               "weight": 0,
+                               "priority":10
+                       }]
+               }
+       }`
+
+       // bind struct
+       var route Route
+       err := json.Unmarshal([]byte(routeStr), &route)
+       assert.Nil(t, err)
+
+       // nodes format
+       nodes := NodesFormat(route.Upstream.Nodes)
+
+       // json encode for client
+       res, err := json.Marshal(nodes)
+       assert.Nil(t, err)
+       jsonStr := string(res)
+       assert.Contains(t, jsonStr, `"weight":0`)
+       assert.Contains(t, jsonStr, `"port":80`)
+       assert.Contains(t, jsonStr, `"host":"::1"`)

Review Comment:
   according to the code, the host should be `[::1]`?



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