Test script to iterate over horizon and count

PHOTO EMBED

Fri Jul 09 2021 08:24:39 GMT+0000 (UTC)

Saved by @jaabsaxo

// Increment variable indices and run another test OR stop
var hIndex = Number(pm.collectionVariables.get("h-index"));
var cIndex = Number(pm.collectionVariables.get("c-index"));

var horizons = JSON.parse(pm.collectionVariables.get("horizons")); 
var counts = JSON.parse(pm.collectionVariables.get("counts")); 

// Run Tests
var nameOfTest = "(H=" + String(horizons[hIndex]) + ", UIC=" + String(counts[cIndex]) + ") Time of firstSampleTime is must be 01:30:00 for intraday horizons";

function getClockTime(timeString) {
    return timeString.split("T")[1]
}

pm.test(nameOfTest, function () {
    if (horizons[hIndex] < 1440) {
        const responseJson = pm.response.json();
        console.log("response", responseJson)
        pm.expect(getClockTime(responseJson.Data[0].Time)).to.eql("01-30-00");
    }
})

if (cIndex + 1 < counts.length) {
    if (hIndex + 1 >= horizons.length) {
        hIndex = 0;
        cIndex = cIndex + 1;
    } else {
        hIndex = hIndex + 1;
    }
    pm.collectionVariables.set("h-index", hIndex);
    pm.collectionVariables.set("c-index", cIndex);
    //postman.setNextRequest('No response data has starting time 01:00:00');
} else {
    pm.collectionVariables.set("cIndex", 0);
}
content_copyCOPY