Copilot commented on code in PR #13065:
URL: https://github.com/apache/apisix/pull/13065#discussion_r2889689505


##########
t/admin/routes-array-nodes.t:
##########
@@ -113,3 +113,60 @@ passed
 GET /t
 --- response_body
 passed
+
+
+
+=== TEST 3: PATCH route from array nodes to hash table nodes
+--- config
+    location /t {
+        content_by_lua_block {
+            local t = require("lib.test_admin").test
+
+            local code, body = t('/apisix/admin/routes/1',
+                ngx.HTTP_PUT,
+                [[{
+                    "uri": "/index.html",
+                    "upstream": {
+                        "nodes": [{
+                            "host": "127.0.0.1",
+                            "port": 8080,
+                            "weight": 1
+                        }],
+                        "type": "roundrobin"
+                    }
+                }]]
+            )
+
+            code, body = t('/apisix/admin/routes/1',
+                ngx.HTTP_PATCH,
+                [[{
+                    "upstream": {
+                        "nodes": {
+                            "127.0.0.1:9200": 1
+                        }
+                    }
+                }]]
+            )
+
+            code, body = t('/apisix/admin/routes/1',
+                ngx.HTTP_PATCH,
+                [[{
+                    "upstream": {
+                        "nodes": [{
+                            "host": "127.0.0.1",
+                            "port": 8080,
+                            "weight": 1
+                        }],
+                        "type": "roundrobin"
+                    }
+                }]]
+            )
+
+            ngx.status = code
+            ngx.say(body)
+        }
+    }
+--- request
+GET /t
+--- response_bodu

Review Comment:
   `--- response_bodu` is misspelled, so this test block won't assert the 
response body as intended (and may be ignored/parsed incorrectly by the test 
harness). Rename it to `--- response_body`.
   ```suggestion
   --- response_body
   ```



##########
t/admin/routes-array-nodes.t:
##########
@@ -113,3 +113,60 @@ passed
 GET /t
 --- response_body
 passed
+
+
+
+=== TEST 3: PATCH route from array nodes to hash table nodes
+--- config
+    location /t {
+        content_by_lua_block {
+            local t = require("lib.test_admin").test
+
+            local code, body = t('/apisix/admin/routes/1',
+                ngx.HTTP_PUT,
+                [[{
+                    "uri": "/index.html",
+                    "upstream": {
+                        "nodes": [{
+                            "host": "127.0.0.1",
+                            "port": 8080,
+                            "weight": 1
+                        }],
+                        "type": "roundrobin"
+                    }
+                }]]
+            )
+
+            code, body = t('/apisix/admin/routes/1',
+                ngx.HTTP_PATCH,
+                [[{
+                    "upstream": {
+                        "nodes": {
+                            "127.0.0.1:9200": 1
+                        }
+                    }
+                }]]
+            )
+
+            code, body = t('/apisix/admin/routes/1',
+                ngx.HTTP_PATCH,
+                [[{
+                    "upstream": {
+                        "nodes": [{
+                            "host": "127.0.0.1",
+                            "port": 8080,
+                            "weight": 1
+                        }],
+                        "type": "roundrobin"
+                    }
+                }]]
+            )

Review Comment:
   This test performs multiple admin calls (PUT, then PATCH array→hash, then 
PATCH hash→array) but only asserts the final call’s result. If the intermediate 
PATCH fails, the test can still pass because later calls overwrite `code/body`. 
Add checks after each call (e.g., `if code >= 300 then ... return end`) so the 
test fails as soon as any step fails, and so it actually verifies both 
conversions.



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