Skip to content

Instantly share code, notes, and snippets.

@nvcnvn
Created September 4, 2019 08:15
Show Gist options
  • Save nvcnvn/df9126c05f2e660af30d1b02c1229057 to your computer and use it in GitHub Desktop.
Save nvcnvn/df9126c05f2e660af30d1b02c1229057 to your computer and use it in GitHub Desktop.
@Purchase
Feature: User able to send request to purchase product
Scenario: The product's quantity is keep when the connection is lost
Given I send request to buy product to the server
And I disconnect the connection before the server receive the request
And I get the response about disconnect
Scenario: The product's quantity is keep when cancel the request
Given I send request to buy product to the server
And I send another request to cancel the previous request
Then I cancel request successful
Scenario: User send request with negative number
Given I send request with JSON body [{"productID": 1, "quantity": -2}, {"productID": 2, "quantity": -1}, ...]
And T get status 400 about negative number and the quantity is not change
Scenario: Check if the request is [{"productID": 1, "quantity": 2}, {"productID": 1, "quantity": 1}, ...], the database [{"productID": 1, "quantity": 5}]
Given I sent request with JSON body [{"productID": 1, "quantity": 2}, {"productID": 1, "quantity": 1}, ...]
Then I get the 400 status and the quantity is not change
Scenario: Check if the request is [{"productID": 1, "quantity": 2}, {"productID": 1, "quantity": 1}, ...], the database [{"productID": 1, "quantity": 2}]
Given I sent request with JSON body [{"productID": 1, "quantity": 2}, {"productID": 1, "quantity": 1}, ...]
Then I get the fail status and the quantity is not change
Scenario: Test response time of request (request per second, transaction per minute, duration of task
Given I send request to buy product to the server
Then I check the response time received from server is under 5 second
Scenario: Send multiple request for 1 product from 1 client will be blocked
Given I sent multiple requests from 1 user to 1 product
And I check that the request will be block if sent in a sort of time
Scenario: Test the commit, lock of database if there are multiple request are sent from multiple client to update 1 product, the database [{"productID": 1, "quantity": 10}]
Given I sent 2 requests [{"productID": 1, "quantity": 2}] and [{"productID": 1, "quantity": 5}] at the same time
And I check that the quantity is updated correctly with remain stocking is [{"productID": 1, "quantity": 3}]
Scenario: Send 1 request to buy 2 product [{"productID": 1, "quantity": 5}, {"productID": 2, "quantity": 6}]
Given I send request with JSON body [{"productID": 1, "quantity": 3}, {"productID": 2, "quantity": 2}]
Then I receive the response with [{"productID": 1, "quantity": 2}, {"productID": 2, "quantity": 4}]
Scenario: Send request to buy 2 product [{"productID": 1, "quantity": 5}, {"productID": 2, "quantity": 6}]
Given I send request with JSON body [{"productID": 1, "quantity": 6}, {"productID": 2, "quantity": 2}]
Then I receive the response with false status and quantity is not change
Scenario: Send 2 requests to buy 2 product [{"productID": 1, "quantity": 5}, {"productID": 2, "quantity": 6}]
Given I send request with JSON body [{"productID": 1, "quantity": 2}, {"productID": 2, "quantity": 3}]
And I send request with JSON body [{"productID": 1, "quantity": 3}, {"productID": 2, "quantity": 1}]
Then I receive the response with [{"productID": 1, "quantity": 0}, {"productID": 2, "quantity": 2}]
Scenario: Send 2 request that 1 product is over stock and 1 in stock [{"productID": 1, "quantity": 10}, {"productID": 2, "quantity": 5}]
Given I send first request with JSON body [{“productID”: 1, “quantity”: 2}, {“productID”: 2, “quantity”: 1}]
And I send second request with JSON body [{"productID": 1, "quantity": 1}, {"productID": 2, "quantity": 5}]
Then I check first request is success and second request is fail, the database is [{“productID”: 1, “quantity”: 8}, {“productID”: 2, “quantity”: 4}]
Scenario: Send 2 request that 1 product is over stock and 1 in stock [{"productID": 1, "quantity": 10}, {"productID": 2, "quantity": 5}]
Given I send first request with JSON body [{"productID": 1, "quantity": 1}, {"productID": 2, "quantity": 5}]
And I send second request with JSON body [{“productID”: 1, “quantity”: 2}, {“productID”: 2, “quantity”: 1}]
Then I check first request is success and second request is fail, the database is [{“productID”: 1, “quantity”: 9}, {“productID”: 2, “quantity”: 0}]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment