From 1d9e0e68c5f839b6aeb2b83632fe8dfb1f47c71f Mon Sep 17 00:00:00 2001 From: roost-io Date: Wed, 6 Sep 2023 15:32:35 +0000 Subject: [PATCH] Test generated by RoostGPT for test dm-integration-test using AI Type Open AI and AI Model gpt-4 --- api_tests/Create_a_new_product.yaml | 43 ++++++++++++++++++++++ api_tests/Delete_an_existing_product.yaml | 37 +++++++++++++++++++ api_tests/Get_a_product_by_ID.yaml | 33 +++++++++++++++++ api_tests/Get_all_products.yaml | 32 ++++++++++++++++ api_tests/Update_an_existing_product.yaml | 45 +++++++++++++++++++++++ 5 files changed, 190 insertions(+) create mode 100644 api_tests/Create_a_new_product.yaml create mode 100644 api_tests/Delete_an_existing_product.yaml create mode 100644 api_tests/Get_a_product_by_ID.yaml create mode 100644 api_tests/Get_all_products.yaml create mode 100644 api_tests/Update_an_existing_product.yaml diff --git a/api_tests/Create_a_new_product.yaml b/api_tests/Create_a_new_product.yaml new file mode 100644 index 00000000..3e5e3477 --- /dev/null +++ b/api_tests/Create_a_new_product.yaml @@ -0,0 +1,43 @@ +// Test generated by RoostGPT for test dm-integration-test using AI Type Open AI and AI Model gpt-4 + +config: + target: "{{ $processEnvironment.SERVER_URL }}/api" + phases: + - duration: 60 + arrivalRate: 20 +scenarios: + - name: "Create a new product and verify the product properties" + flow: + # This scenario is to create a new product and verify the product properties + - post: + # Assigning meaningful name to the variables + url: "/products" + headers: + Content-Type: "application/json" + json: + name: "Test Product" + description: "This is a test product." + price: 10.0 + # Capture the productId from the response for further use + capture: + json: "$.productId" + as: "productId" + # Assert the response to validate the status code and presence of productId + expect: + - statusCode: 201 + - hasProperty: "productId" + - get: + # Use the captured productId to get the details of the created product + url: "/products/{{ productId }}" + # Assert the response to validate the status code and the product properties + expect: + - statusCode: 200 + - equals: + - "name" + - "Test Product" + - equals: + - "description" + - "This is a test product." + - equals: + - "price" + - 10.0 diff --git a/api_tests/Delete_an_existing_product.yaml b/api_tests/Delete_an_existing_product.yaml new file mode 100644 index 00000000..6a513616 --- /dev/null +++ b/api_tests/Delete_an_existing_product.yaml @@ -0,0 +1,37 @@ +// Test generated by RoostGPT for test dm-integration-test using AI Type Open AI and AI Model gpt-4 + +config: + target: "{{ $processEnvironment.SERVER_URL }}/api" + phases: + - duration: 60 + arrivalRate: 20 +scenarios: + - name: "Delete an existing product" + flow: + # Scenario: Fetch product details before deletion + - get: + url: "/products/1" + headers: + Content-Type: "application/json" + expect: + # Expecting a successful response with product details + - statusCode: 200 + - hasProperty: "name" + - hasProperty: "description" + - hasProperty: "price" + # Scenario: Delete the fetched product + - delete: + url: "/products/1" + headers: + Content-Type: "application/json" + expect: + # Expecting a successful deletion response + - statusCode: 200 + # Scenario: Verify if the product is deleted + - get: + url: "/products/1" + headers: + Content-Type: "application/json" + expect: + # Expecting a response indicating that the product does not exist + - statusCode: 404 diff --git a/api_tests/Get_a_product_by_ID.yaml b/api_tests/Get_a_product_by_ID.yaml new file mode 100644 index 00000000..9ba2087e --- /dev/null +++ b/api_tests/Get_a_product_by_ID.yaml @@ -0,0 +1,33 @@ +// Test generated by RoostGPT for test dm-integration-test using AI Type Open AI and AI Model gpt-4 + +config: + target: "{{ $processEnvironment.SERVER_URL }}/api" + phases: + - duration: 60 + arrivalRate: 20 +scenarios: + - name: "Get a product by ID" + comment: "This scenario tests the retrieval of a product by its ID. The expected outcome is a successful response (200) with the product details." + flow: + - get: + url: "/products/1" + headers: + content-type: "application/json" + expect: + - statusCode: 200 + - hasProperty: "productId" + - equals: + - "productId" + - 1 + - hasProperty: "name" + - hasProperty: "description" + - hasProperty: "price" + - match: + json: "$.name" + regex: ".+" + - match: + json: "$.description" + regex: ".+" + - match: + json: "$.price" + regex: "\d+" diff --git a/api_tests/Get_all_products.yaml b/api_tests/Get_all_products.yaml new file mode 100644 index 00000000..19e51f50 --- /dev/null +++ b/api_tests/Get_all_products.yaml @@ -0,0 +1,32 @@ +// Test generated by RoostGPT for test dm-integration-test using AI Type Open AI and AI Model gpt-4 + +config: + target: "{{ $processEnvironment.SERVER_URL }}/api" + phases: + - duration: 60 + arrivalRate: 20 +scenarios: + - name: "Get all products" + flow: + - get: + url: "/products" + headers: + content-type: "application/json" + capture: + - json: "$.products" + as: "products" + expect: + - statusCode: 200 + - hasProperty: "products" + - equals: + products: [] + - hasProperty: "id" + - hasProperty: "name" + - hasProperty: "description" + - hasProperty: "price" + - equals: + id: 10 + name: "apple" + description: "description of the product" + price: 20 +# This scenario is testing the GET /products API endpoint. The expected behavior is that the API returns a 200 status code, and the response body contains a "products" property. The "products" property should be an empty array, indicating that there are no products. Additionally, the response body should contain "id", "name", "description", and "price" properties. The values of these properties should match the expected values. diff --git a/api_tests/Update_an_existing_product.yaml b/api_tests/Update_an_existing_product.yaml new file mode 100644 index 00000000..aa21e72d --- /dev/null +++ b/api_tests/Update_an_existing_product.yaml @@ -0,0 +1,45 @@ +// Test generated by RoostGPT for test dm-integration-test using AI Type Open AI and AI Model gpt-4 + +config: + target: "{{ $processEnvironment.SERVER_URL }}/api" + phases: + - duration: 60 + arrivalRate: 20 +scenarios: + - name: "Update an existing product" + comment: "This scenario tests the successful update of an existing product with ID 1." + flow: + - post: + url: "/products/1" + headers: + $ref: "#/definitions/headers" + json: + $ref: "#/definitions/productUpdatePayload" + capture: + json: "$.productId" + as: "productId" + expect: + - statusCode: 200 + - equals: + - "{{ productId }}" + - "1" + - get: + url: "/products/{{ productId }}" + expect: + - statusCode: 200 + - equals: + - "{{ response.body.name }}" + - "Updated Product" + - equals: + - "{{ response.body.description }}" + - "This is an updated test product." + - equals: + - "{{ response.body.price }}" + - 15.0 +definitions: + headers: + Content-Type: "application/json" + productUpdatePayload: + name: "Updated Product" + description: "This is an updated test product." + price: 15.0