You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by "nic-chen (via GitHub)" <gi...@apache.org> on 2023/03/15 10:08:19 UTC
[GitHub] [apisix-dashboard] nic-chen commented on a diff in pull request #2766: feat: support ipv6 in upstream nodes
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: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org