Skip to content

Instantly share code, notes, and snippets.

@steverhall
Created July 30, 2020 00:19
Show Gist options
  • Save steverhall/ef1f52a15ca4b8c642c0d6ca6c3b0670 to your computer and use it in GitHub Desktop.
Save steverhall/ef1f52a15ca4b8c642c0d6ca6c3b0670 to your computer and use it in GitHub Desktop.
PostMan Test script to insert random data into POST
//BODY payload
//{
// "datetime": "{{requesttime}}",
// "requestor": "{{requestor}}",
// "status": "requested",
// "details": "Tutoring on project",
// "rate": "50",
// "requestfree": false,
// "expert": "{{expert}}",
// "repo": "{{repo}}"
//}
//TEST
pm.test("Insert data", function() {
var timeslot = Math.trunc(Math.random() * 8) + 9;
var day = Math.trunc(Math.random() * 30) + 1;
day = ('00' + day).slice(-2);
timeslot = ('00' + timeslot).slice(-2);
requestor = ["steverhall", "robdavisms", "nilofer", "Zakeelm", "c-w"];
tutor = ["patniko", "steverhall", "robdavisms"];
reqnum = Math.trunc(Math.random() * 5);
tutnum = Math.trunc(Math.random() * 3);
pm.environment.set("repo", "github-experts+github-experts-sample-repo");
pm.environment.set("requestor", requestor[reqnum]);
pm.environment.set("expert", tutor[tutnum]);
pm.environment.set("requesttime", "2020-08-" + day + "T" + timeslot + ":00");
console.log("2020-08-" + day + "T" + timeslot + ":00")
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment