/
AngelCareMe
/
task_queue
Обзор
Документация
Войти
/
AngelCareMe
/
task_queue
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
task_queue_api_with_tests.postman_collection.json
549 строк
23 KB
AngelCareMe
done
28 июл 2025, 21:07
28 июл 2025, 21:07
c70014b
Код
Авторство
О чём код?
{ "info": { "_postman_id": "task-queue-api-test-with-tests", "name": "Task Queue API with Tests", "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json" }, "item": [ { "name": "Health", "item": [ { "name": "Check Health", "event": [ { "listen": "test", "script": { "exec": [ "pm.test(\"Status code is 200\", function () {", " pm.response.to.have.status(200);", "});", "", "pm.test(\"Response has status field\", function () {", " const jsonData = pm.response.json();", " pm.expect(jsonData).to.have.property('status');", "});", "", "pm.test(\"Response has services field\", function () {", " const jsonData = pm.response.json();", " pm.expect(jsonData).to.have.property('services');", "});" ], "type": "text/javascript" } } ], "request": { "method": "GET", "header": [], "url": { "raw": "{{base_url}}/api/v1/health", "host": [ "{{base_url}}" ], "path": [ "api", "v1", "health" ] } }, "response": [] } ] }, { "name": "Tasks", "item": [ { "name": "Create Task", "event": [ { "listen": "test", "script": { "exec": [ "pm.test(\"Status code is 201\", function () {", " pm.response.to.have.status(201);", "});", "", "pm.test(\"Response has required fields\", function () {", " const jsonData = pm.response.json();", " pm.expect(jsonData).to.have.property('id');", " pm.expect(jsonData).to.have.property('name');", " pm.expect(jsonData).to.have.property('status');", " pm.expect(jsonData).to.have.property('created_at');", "});", "", "// Сохраняем ID задачи для последующих тестов", "pm.environment.set(\"task_id\", pm.response.json().id);", "", "pm.test(\"Task name is correct\", function () {", " const jsonData = pm.response.json();", " pm.expect(jsonData.name).to.eql(pm.environment.get(\"task_name\"));", "});" ], "type": "text/javascript" } } ], "request": { "method": "POST", "header": [ { "key": "Content-Type", "value": "application/json" } ], "body": { "mode": "raw", "raw": "{\n \"name\": \"{{task_name}}\",\n \"payload\": \"{{task_payload}}\",\n \"max_retry\": {{task_max_retry}},\n \"delay\": {{task_delay}}\n}" }, "url": { "raw": "{{base_url}}/api/v1/tasks", "host": [ "{{base_url}}" ], "path": [ "api", "v1", "tasks" ] } }, "response": [] }, { "name": "Get Task By ID", "event": [ { "listen": "test", "script": { "exec": [ "pm.test(\"Status code is 200\", function () {", " pm.response.to.have.status(200);", "});", "", "pm.test(\"Response has required fields\", function () {", " const jsonData = pm.response.json();", " pm.expect(jsonData).to.have.property('id');", " pm.expect(jsonData).to.have.property('name');", " pm.expect(jsonData).to.have.property('status');", " pm.expect(jsonData).to.have.property('created_at');", "});", "", "pm.test(\"Task ID matches\", function () {", " const jsonData = pm.response.json();", " pm.expect(jsonData.id).to.eql(pm.environment.get(\"task_id\"));", "});" ], "type": "text/javascript" } } ], "request": { "method": "GET", "header": [], "url": { "raw": "{{base_url}}/api/v1/tasks/{{task_id}}", "host": [ "{{base_url}}" ], "path": [ "api", "v1", "tasks", "{{task_id}}" ] } }, "response": [] }, { "name": "List Tasks", "event": [ { "listen": "test", "script": { "exec": [ "pm.test(\"Status code is 200\", function () {", " pm.response.to.have.status(200);", "});", "", "pm.test(\"Response is array or has tasks array\", function () {", " const jsonData = pm.response.json();", " // Может возвращать объект с полем tasks или сразу массив", " pm.expect(jsonData.tasks || jsonData).to.be.an('array');", "});" ], "type": "text/javascript" } } ], "request": { "method": "GET", "header": [], "url": { "raw": "{{base_url}}/api/v1/tasks?limit=10&offset=0", "host": [ "{{base_url}}" ], "path": [ "api", "v1", "tasks" ], "query": [ { "key": "limit", "value": "10" }, { "key": "offset", "value": "0" } ] } }, "response": [] }, { "name": "Retry Task", "event": [ { "listen": "test", "script": { "exec": [ "pm.test(\"Status code is 200\", function () {", " pm.response.to.have.status(200);", "});", "", "pm.test(\"Response has message field\", function () {", " const jsonData = pm.response.json();", " pm.expect(jsonData).to.have.property('message');", "});" ], "type": "text/javascript" } } ], "request": { "method": "POST", "header": [], "url": { "raw": "{{base_url}}/api/v1/tasks/{{task_id}}/retry", "host": [ "{{base_url}}" ], "path": [ "api", "v1", "tasks", "{{task_id}}", "retry" ] } }, "response": [] }, { "name": "Delete Task", "event": [ { "listen": "test", "script": { "exec": [ "pm.test(\"Status code is 200\", function () {", " pm.response.to.have.status(200);", "});", "", "pm.test(\"Response has message field\", function () {", " const jsonData = pm.response.json();", " pm.expect(jsonData).to.have.property('message');", "});" ], "type": "text/javascript" } } ], "request": { "method": "DELETE", "header": [], "url": { "raw": "{{base_url}}/api/v1/tasks/{{task_id}}", "host": [ "{{base_url}}" ], "path": [ "api", "v1", "tasks", "{{task_id}}" ] } }, "response": [] }, { "name": "Get Task Statistics", "event": [ { "listen": "test", "script": { "exec": [ "pm.test(\"Status code is 200\", function () {", " pm.response.to.have.status(200);", "});", "", "pm.test(\"Response has required statistic fields\", function () {", " const jsonData = pm.response.json();", " pm.expect(jsonData).to.have.property('total');", " pm.expect(jsonData).to.have.property('pending');", " pm.expect(jsonData).to.have.property('processing');", " pm.expect(jsonData).to.have.property('success');", " pm.expect(jsonData).to.have.property('failed');", "});", "", "pm.test(\"Statistic fields are numbers\", function () {", " const jsonData = pm.response.json();", " pm.expect(jsonData.total).to.be.a('number');", " pm.expect(jsonData.pending).to.be.a('number');", " pm.expect(jsonData.processing).to.be.a('number');", " pm.expect(jsonData.success).to.be.a('number');", " pm.expect(jsonData.failed).to.be.a('number');", "});" ], "type": "text/javascript" } } ], "request": { "method": "GET", "header": [], "url": { "raw": "{{base_url}}/api/v1/tasks/stats", "host": [ "{{base_url}}" ], "path": [ "api", "v1", "tasks", "stats" ] } }, "response": [] } ] }, { "name": "Metrics", "item": [ { "name": "Get System Metrics", "event": [ { "listen": "test", "script": { "exec": [ "pm.test(\"Status code is 200\", function () {", " pm.response.to.have.status(200);", "});", "", "pm.test(\"Response has task_metrics field\", function () {", " const jsonData = pm.response.json();", " pm.expect(jsonData).to.have.property('task_metrics');", "});" ], "type": "text/javascript" } } ], "request": { "method": "GET", "header": [], "url": { "raw": "{{base_url}}/api/v1/metrics", "host": [ "{{base_url}}" ], "path": [ "api", "v1", "metrics" ] } }, "response": [] }, { "name": "Get Task Metrics", "event": [ { "listen": "test", "script": { "exec": [ "pm.test(\"Status code is 200\", function () {", " pm.response.to.have.status(200);", "});", "", "pm.test(\"Response has required metric fields\", function () {", " const jsonData = pm.response.json();", " pm.expect(jsonData).to.have.property('total_tasks');", " pm.expect(jsonData).to.have.property('pending_tasks');", " pm.expect(jsonData).to.have.property('processing_tasks');", " pm.expect(jsonData).to.have.property('success_tasks');", " pm.expect(jsonData).to.have.property('failed_tasks');", "});" ], "type": "text/javascript" } } ], "request": { "method": "GET", "header": [], "url": { "raw": "{{base_url}}/api/v1/metrics/tasks", "host": [ "{{base_url}}" ], "path": [ "api", "v1", "metrics", "tasks" ] } }, "response": [] } ] }, { "name": "Error Handling", "item": [ { "name": "Get Non-existent Task", "event": [ { "listen": "test", "script": { "exec": [ "pm.test(\"Status code is 404\", function () {", " pm.response.to.have.status(404);", "});" ], "type": "text/javascript" } } ], "request": { "method": "GET", "header": [], "url": { "raw": "{{base_url}}/api/v1/tasks/00000000-0000-0000-0000-000000000000", "host": [ "{{base_url}}" ], "path": [ "api", "v1", "tasks", "00000000-0000-0000-0000-000000000000" ] } }, "response": [] }, { "name": "Create Task with Invalid Data", "event": [ { "listen": "test", "script": { "exec": [ "pm.test(\"Status code is 400\", function () {", " pm.response.to.have.status(400);", "});" ], "type": "text/javascript" } } ], "request": { "method": "POST", "header": [ { "key": "Content-Type", "value": "application/json" } ], "body": { "mode": "raw", "raw": "{\n \"name\": \"\",\n \"payload\": \"test payload\",\n \"max_retry\": -1,\n \"delay\": -10\n}" }, "url": { "raw": "{{base_url}}/api/v1/tasks", "host": [ "{{base_url}}" ], "path": [ "api", "v1", "tasks" ] } }, "response": [] } ] } ], "event": [ { "listen": "prerequest", "script": { "type": "text/javascript", "exec": [ "" ] } }, { "listen": "test", "script": { "type": "text/javascript", "exec": [ "" ] } } ], "variable": [ { "key": "base_url", "value": "http://localhost:8080" }, { "key": "task_id", "value": "" }, { "key": "task_name", "value": "test_task_from_postman" }, { "key": "task_payload", "value": "test payload data from Postman" }, { "key": "task_max_retry", "value": "3" }, { "key": "task_delay", "value": "0" } ] }