‘’'Hi I’m new, hope someone could help, so below is the response that I’m getting on the end point I’m working on. The end point filters the accounts that the user will search by userid or gameid.
The end point is working well at the moment. What I’m trying to achieve is , to check all user id with in the array has the same value (To make sure that the API is filtering query properly). Included is my test script, the script works well and is able to check all the value in user_id, (I’m using variables by the way.). My concern is the end points get updated almost every day, Accounts are being deleted and added everyday. Is there a way to make my script shorter and able to cope up with the updates. thanks
*Details *:
{
"error": false,
"message": "Successfully loaded ",
"data": {
"accounts": [
{
"id": 7,
"user_id": 8,
"game_id": 1,
"guild_id": 2,
"game_account_limit": 7,
"wallet_address": "20dadawd",
"game_accounts": []
},
{
"id": 8,
"user_id": 8,
"game_id": 3,
"guild_id": 2,
"game_account_limit": 13,
"wallet_address": "card",
"game_accounts": []
},
{
"id": 9,
"user_id": 8,
"game_id": 3,
"guild_id": 2,
"game_account_limit": 13,
"wallet_address": "feed",
"game_accounts": []
},
{
"id": 11,
"user_id": 8,
"game_id": 3,
"guild_id": 2,
"game_account_limit": 13,
"wallet_address": "feed",
"game_accounts": []
},
{
"id": 12,
"user_id": 8,
"game_id": 3,
"guild_id": 2,
"game_account_limit": 13,
"wallet_address": "interface",
"game_accounts": []
},
{
"id": 14,
"user_id": 8,
"game_id": 1,
"guild_id": 1,
"game_account_limit": 13,
"wallet_address": "system",
"game_accounts": []
},
{
"id": 17,
"user_id": 8,
"game_id": 1,
"guild_id": 1,
"game_account_limit": 13,
"wallet_address": "alarm",
"game_accounts": []
},
{
"id": 18,
"user_id": 8,
"game_id": 1,
"guild_id": 1,
"game_account_limit": 13,
"wallet_address": "sensor",
"game_accounts": []
},
{
"id": 19,
"user_id": 8,
"game_id": 1,
"guild_id": 1,
"game_account_limit": 13,
"wallet_address": "interface",
"game_accounts": []
},
{
"id": 20,
"user_id": 8,
"game_id": 1,
"guild_id": 1,
"game_account_limit": 13,
"wallet_address": "alarm",
"game_accounts": []
}
],
"current_page": 1,
"total_pages": 2,
"total_results": 14
}
}
I’ve already tried:
‘’'pm.test('Test: Filter game account via usser id ', function() {
pm.response.to.have.status(200);
});
var jsonData = pm.response.json()
pm.test(“ONLY a declared user id should be returned”, () => {
const responseJson = pm.response.json();
pm.expect(responseJson.data.accounts[0].user_id).to.eql(pm.environment.get(“userid”));
pm.expect(responseJson.data.accounts[1].user_id).to.eql(pm.environment.get(“userid”));
pm.expect(responseJson.data.accounts[2].user_id).to.eql(pm.environment.get(“userid”));
pm.expect(responseJson.data.accounts[3].user_id).to.eql(pm.environment.get(“userid”));
pm.expect(responseJson.data.accounts[4].user_id).to.eql(pm.environment.get(“userid”));
pm.expect(responseJson.data.accounts[5].user_id).to.eql(pm.environment.get(“userid”));
});