Pet owner and store

This commit is contained in:
2026-04-06 15:50:45 -06:00
parent d3754c8018
commit 9655a77972
9 changed files with 236 additions and 33 deletions

View File

@@ -564,7 +564,7 @@
"name": "Get All Pets",
"request": {
"method": "GET",
"url": "{{baseUrl}}/api/v1/pets",
"url": "{{baseUrl}}/api/v1/pets?status=available&storeId=1",
"header": [
{
"key": "Content-Type",
@@ -585,7 +585,10 @@
"exec": [
"pm.test('Status code is 200', function () {",
" pm.response.to.have.status(200);",
"});"
"});",
"var json = pm.response.json();",
"pm.test('is page response', function () { pm.expect(json.content).to.be.an('array'); });",
"pm.test('all pets have storeName', function () { json.content.forEach(function(p) { pm.expect(p).to.have.property('storeName'); }); });"
]
}
}
@@ -616,7 +619,10 @@
"exec": [
"pm.test('Status code is 200', function () {",
" pm.response.to.have.status(200);",
"});"
"});",
"var json = pm.response.json();",
"pm.test('has petId', function () { pm.expect(json.petId).to.be.a('number'); });",
"pm.test('has owner fields', function () { pm.expect(json).to.have.all.keys('petId','petName','petSpecies','petBreed','petAge','petStatus','petPrice','imageUrl','createdAt','updatedAt','customerId','customerName','storeId','storeName'); });"
]
}
}
@@ -671,7 +677,7 @@
],
"body": {
"mode": "raw",
"raw": "{\n \"petName\": \"Postman Pet\",\n \"petSpecies\": \"Dog\",\n \"petBreed\": \"Mixed\",\n \"petAge\": 2,\n \"petStatus\": \"Available\",\n \"petPrice\": 350.00\n}",
"raw": "{\n \"petName\": \"Postman Pet\",\n \"petSpecies\": \"Dog\",\n \"petBreed\": \"Mixed\",\n \"petAge\": 2,\n \"petStatus\": \"Available\",\n \"petPrice\": 350.00,\n \"storeId\": 1\n}",
"options": {
"raw": {
"language": "json"
@@ -689,7 +695,11 @@
" pm.response.to.have.status(201);",
"});",
"var jsonData = pm.response.json();",
"if (jsonData.petId !== undefined) pm.collectionVariables.set('petId', jsonData.petId);"
"if (jsonData.petId !== undefined) pm.collectionVariables.set('petId', jsonData.petId);",
"pm.test('has petId', function () { pm.expect(jsonData.petId).to.be.a('number'); });",
"pm.test('has storeId', function () { pm.expect(jsonData.storeId).to.equal(1); });",
"pm.test('has storeName', function () { pm.expect(jsonData.storeName).to.be.a('string'); });",
"pm.test('customerId is null', function () { pm.expect(jsonData.customerId).to.be.null; });"
]
}
}
@@ -713,7 +723,7 @@
],
"body": {
"mode": "raw",
"raw": "{\n \"petName\": \"Postman Pet Updated\",\n \"petSpecies\": \"Dog\",\n \"petBreed\": \"Mixed\",\n \"petAge\": 3,\n \"petStatus\": \"Available\",\n \"petPrice\": 375.00\n}",
"raw": "{\n \"petName\": \"Postman Pet Updated\",\n \"petSpecies\": \"Dog\",\n \"petBreed\": \"Mixed\",\n \"petAge\": 3,\n \"petStatus\": \"Owned\",\n \"petPrice\": 375.00,\n \"customerId\": 1\n}",
"options": {
"raw": {
"language": "json"
@@ -729,7 +739,12 @@
"exec": [
"pm.test('Status code is 200', function () {",
" pm.response.to.have.status(200);",
"});"
"});",
"var json = pm.response.json();",
"pm.test('status is Owned', function () { pm.expect(json.petStatus).to.equal('Owned'); });",
"pm.test('has customerId', function () { pm.expect(json.customerId).to.be.a('number'); });",
"pm.test('has customerName', function () { pm.expect(json.customerName).to.be.a('string'); });",
"pm.test('storeId is null', function () { pm.expect(json.storeId).to.be.null; });"
]
}
}