151 lines
3.0 KiB
HTTP
151 lines
3.0 KiB
HTTP
# @import ./PreScript.http
|
|
###
|
|
|
|
GET /products/1
|
|
?? status == 200
|
|
?? body product_name == Chai
|
|
?? body id == 1
|
|
|
|
###
|
|
GET /products
|
|
?? status == 200
|
|
?? body length == 77
|
|
|
|
###
|
|
GET /products?discontinued=neq.0
|
|
?? status == 200
|
|
?? body length == 10
|
|
|
|
###
|
|
GET /products?unit_price=is.null
|
|
?? status == 200
|
|
?? body length == 0
|
|
|
|
###
|
|
GET /products?product_name=in.(Chai,Chang,Aniseed Syrup)
|
|
?? status == 200
|
|
?? body length == 3
|
|
{{
|
|
const {expect} = require('chai');
|
|
let responseItems = JSON.parse(response.body);
|
|
test("OK in", () =>
|
|
{
|
|
expect(responseItems[0].id).to.equal(1);
|
|
expect(responseItems[1].id).to.equal(2);
|
|
expect(responseItems[2].id).to.equal(3);
|
|
})
|
|
}}
|
|
|
|
###
|
|
GET /products?id=in.(1,2,79)
|
|
?? status == 200
|
|
?? body length == 2
|
|
{{
|
|
const {expect} = require('chai');
|
|
let responseItems = JSON.parse(response.body);
|
|
test("OK in", () =>
|
|
{
|
|
expect(responseItems[0].id).to.equal(1);
|
|
expect(responseItems[1].id).to.equal(2);
|
|
})
|
|
}}
|
|
|
|
###
|
|
POST /products
|
|
Content-Type: application/json
|
|
|
|
{
|
|
"id": 78,
|
|
"product_name": "Saffaron",
|
|
"discontinued": 0,
|
|
"supplier_id": 12,
|
|
"category_id": 2,
|
|
"quantity_per_unit": "20 mg",
|
|
"unit_price": 100,
|
|
"units_in_stock": 50,
|
|
"units_on_order": 0,
|
|
"reorder_level": 10
|
|
}
|
|
?? status == 201
|
|
|
|
###
|
|
{{
|
|
const axios = require('axios');
|
|
|
|
let postData = {
|
|
"id": 78,
|
|
"product_name": "Saffaron",
|
|
"discontinued": 0,
|
|
"supplier_id": 12,
|
|
"category_id": 2,
|
|
"quantity_per_unit": "20 mg",
|
|
"unit_price": 100,
|
|
"units_in_stock": 50,
|
|
"units_on_order": 0,
|
|
"reorder_level": 10
|
|
}
|
|
const wait = axios.post(`${host}/products`, postData, {headers:{ 'Content-Type': 'application/json'} }).then(res => {
|
|
return null;
|
|
})
|
|
exports.wait = wait;
|
|
}}
|
|
|
|
PATCH /products?id=eq.78
|
|
Content-Type: application/json
|
|
|
|
{
|
|
"product_name": "Saffaron-patch"
|
|
}
|
|
?? status == 204
|
|
|
|
{{
|
|
const {expect} = require('chai');
|
|
const axios = require("axios");
|
|
|
|
const wait = axios.get(`${host}/products?id=eq.78`).then(res => {
|
|
test("Check Patch", () =>
|
|
{
|
|
expect(res.data[0].product_name).to.equal("Saffaron-patch")
|
|
})
|
|
})
|
|
exports.wait = wait;
|
|
}}
|
|
|
|
###
|
|
|
|
{{
|
|
const axios = require('axios');
|
|
|
|
let postData = {
|
|
"id": 78,
|
|
"product_name": "Saffaron",
|
|
"discontinued": 0,
|
|
"supplier_id": 12,
|
|
"category_id": 2,
|
|
"quantity_per_unit": "20 mg",
|
|
"unit_price": 100,
|
|
"units_in_stock": 50,
|
|
"units_on_order": 0,
|
|
"reorder_level": 10
|
|
}
|
|
const wait = axios.post(`${host}/products`, postData, {headers:{ 'Content-Type': 'application/json'} } ).then(res => {
|
|
return null;
|
|
})
|
|
exports.wait = wait;
|
|
}}
|
|
|
|
DELETE /products?id=eq.78
|
|
?? status == 204
|
|
|
|
{{
|
|
const {expect} = require('chai');
|
|
const axios = require("axios");
|
|
|
|
const wait = axios.get(`${host}/products`).then(res => {
|
|
test("Check for Delete", () => {
|
|
expect(res.data.length).to.equal(77);
|
|
})
|
|
})
|
|
exports.wait = wait;
|
|
}}
|