UNPKG

@apica-io/asm-pm-runner

Version:

Run a postman collection in Apica ASM.

100 lines (99 loc) 4.81 kB
{ "info": { "_postman_id": "802f01d5-5fca-4ed3-93ee-51b34cd1181e", "name": "IF API Test", "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json", "_exporter_id": "11170664" }, "item": [ { "name": "New Request", "event": [ { "listen": "test", "script": { "exec": [ "var res = {", " \"ApiName\": \"Photo Inspection Api\",", " \"ApiStatus\": \"Healthy\",", " \"ApiTotalDuration\": \"00:00:01.2363662\",", " \"Components\": [", " {\"ComponentName\": \"Stargate\", \"ComponentStatus\": \"Healthy\", \"ComponentDuration\": \"00:00:00.1046241\", \"Comment\": null},", " {\"ComponentName\": \"Yellow Pages\", \"ComponentStatus\": \"Healthy\", \"ComponentDuration\": \"00:00:01.2346786\", \"Comment\": null},", " {\"ComponentName\": \"LaunchDarkly\", \"ComponentStatus\": \"unHealthy\", \"ComponentDuration\": \"00:00:00.0000369\", \"Comment\": null},", " {\"ComponentName\": \"PartnerDirectory\", \"ComponentStatus\": \"Healthy\", \"ComponentDuration\": \"00:00:00.2204359\", \"Comment\": null},", " {\"ComponentName\": \"BluePilot\", \"ComponentStatus\": \"Healthy\", \"ComponentDuration\": \"00:00:00.1686577\", \"Comment\": null},", " {\"ComponentName\": \"Claims.DocumentStore\", \"ComponentStatus\": \"Healthy\", \"ComponentDuration\": \"00:00:00.8809496\", \"Comment\": null},", " {\"ComponentName\": \"windscreen\", \"ComponentStatus\": \"Healthy\", \"ComponentDuration\": \"00:00:00.1339307\", \"Comment\": null},", " {\"ComponentName\": \"documents\", \"ComponentStatus\": \"unHealthy\", \"ComponentDuration\": \"00:00:00.1321738\", \"Comment\": null},", " {\"ComponentName\": \"Users\", \"ComponentStatus\": \"Healthy\", \"ComponentDuration\": \"00:00:00.1337138\", \"Comment\": null},", " {\"ComponentName\": \"WorkshopUIRecords\", \"ComponentStatus\": \"Healthy\", \"ComponentDuration\": \"00:00:00.1376907\", \"Comment\": null},", " {\"ComponentName\": \"GlassInspection\", \"ComponentStatus\": \"Healthy\", \"ComponentDuration\": \"00:00:00.1399904\", \"Comment\": null},", " {\"ComponentName\": \"WorkshopUIPhotos\", \"ComponentStatus\": \"Healthy\", \"ComponentDuration\": \"00:00:00.1348779\", \"Comment\": null},", " {\"ComponentName\": \"Document\", \"ComponentStatus\": \"Healthy\", \"ComponentDuration\": \"00:00:00.1358473\", \"Comment\": null}", " ]", "};", "", "var unhealthyComponents = [];", "", "for (var i = 0; i < res.Components.length; i++) {", " if (res.Components[i].ComponentStatus != \"Healthy\") {", " unhealthyComponents.push(res.Components[i].ComponentName);", " }", "}", "", "var resultmessage = \"\";", "", "if (unhealthyComponents.length == 0) {", " resultmessage = \"All components are healthy!\";", "} else {", " resultmessage = \"Components that are not healthy:\\r\\n\";", " for (var j = 0; j < unhealthyComponents.length; j++) {", " resultmessage += \"#\" + (j + 1) + \": \" + unhealthyComponents[j] + \"\\r\\n\";", " }", "}", "", "var resultValue = unhealthyComponents.length;", "", "pm.collectionVariables.set(\"_Apica_ReturnValue\", resultValue);", "pm.collectionVariables.set(\"_Apica_Message\", resultmessage);", "", "console.log(resultmessage);", "console.log(resultValue);", "", "if (unhealthyComponents.length > 0) {", " tests[\"Some components unhealthy!\"] = false;", "} else {", " tests[\"All healthy!\"] = true;", "}" ], "type": "text/javascript" } } ], "request": { "method": "GET", "header": [], "url": { "raw": "www.example.com", "host": [ "www", "example", "com" ] } }, "response": [] } ], "variable": [ { "key": "_Apica_ReturnValue", "value": "" }, { "key": "_Apica_Message", "value": "" } ] }