From fceded680eb9b5377f27f81050d1a97d44f93350 Mon Sep 17 00:00:00 2001 From: Henry Batt <37820016+henrybatt@users.noreply.github.com> Date: Thu, 30 May 2024 04:30:20 +0000 Subject: [PATCH] Update tests to create the driver it uses --- k6.js | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/k6.js b/k6.js index 34e896f7..942032df 100644 --- a/k6.js +++ b/k6.js @@ -13,7 +13,7 @@ function simulateUserLoginTest() { const params = { headers: { 'Content-Type': 'application/json' } }; let response = http.post(url, payload, params); - check(response, { 'is status 200': (r) => r.status === 200 }); + check(response, { 'Fetch Driver Profile': (r) => r.status === 200 }); sleep(1); } @@ -96,9 +96,27 @@ export const options = { // vus: 2000, // iterations: 1, // exec: 'simulateUserLogin' - // } + // } }; +export function setup() { + // Create a driver user + let url = `${ENDPOINT}/driver/create`; + const payload = JSON.stringify({ + "username": "jDoe11", + "password": "53%32", + "name": "John Doe", + "phone_number": "1234567890", + "email": "john.doe1@example.com", + "max_available_seats": 4, + "licence_plate": "319IRG" + }); + const params = { headers: { 'Content-Type': 'application/json' } }; + let response = http.post(url, payload, params); + check(response, { 'Sign Up a Driver': (r) => r.status === 201 }); + +} + export function simulateUserLogin() { group('User Actions', function () { simulateUserLoginTest();