From 4d5c3693de0a6e7fbe4f5e0c0e5298305ac39b85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=98=BF=E7=94=B7?= Date: Sun, 12 Sep 2021 21:10:38 +0800 Subject: [PATCH] test task creation (#21) * test post * add test post --- prod/upload/upload.lua | 2 +- test/test_post.lua | 29 +++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 test/test_post.lua diff --git a/prod/upload/upload.lua b/prod/upload/upload.lua index 46466f7..5aca65d 100644 --- a/prod/upload/upload.lua +++ b/prod/upload/upload.lua @@ -64,7 +64,7 @@ while true do { method = "POST", headers = { - host = "ngx" + ["Content-Type"] = "application/json" }, body = { cjson.encode({task_type = 1, data = files}) diff --git a/test/test_post.lua b/test/test_post.lua new file mode 100644 index 0000000..d5eae4f --- /dev/null +++ b/test/test_post.lua @@ -0,0 +1,29 @@ +local httpc = require("resty.http").new() + +-- Single-shot requests use the `request_uri` interface. +local res, err = httpc:request_uri("http://127.0.0.1:8080/api/v1/ts/create_task", { + method = "POST", + headers = { + ["Content-Type"] = "application/json", + }, + body = [[ + { + "created_at": "2021-08-30T11:34:25.845915", + "created_by": "quarkus_test", + "data": { + "pics": [ + "23f64c00-14d3-4e8a-bc73-10bfe79cd172", + "66ea4c4f-6394-4f97-92ea-e5cde4061d05", + "4ea1df10-b3a9-4f3c-8687-7e12c029e17b" + ] + }, + "task_status": "PENDING", + "task_type": "UPLOAD_PICTURE", + "updated_at": "2021-08-30T11:34:25.845929", + "updated_by": "quarkus_test" +} + ]] +}) + +ngx.say(res.status) +ngx.say(err)