meta {
  name: Get summary (today)
  type: http
  seq: 1
}

get {
  url: {{BASE_URL}}/api/summary?interval=today
  body: none
  auth: bearer
}

params:query {
  interval: today
}

auth:bearer {
  token: {{WRITEUSER_TOKEN}}
}

assert {
  res.status: eq 200
  res('user_id'): eq writeuser
  res('projects'): length 1
  res('languages'): length 1
  res('editors'): length 1
  res('operating_systems'): length 1
  res('machines'): length 1
  res('branches'): isNull
}

tests {
  // const moment = require('moment')
  
  /*
  // This is something the unit tests are supposed to check
  // pm.test("Correct summary range", function () {
  //     const jsonData = pm.response.json();
      const from = moment(jsonData.from)
      const to = moment(jsonData.to)
  
  //     pm.expect(moment.duration(moment().diff(from.add(2, 'm'))).asSeconds()).to.lt(10); // first heartbeat is now minus 1 min minus some latency
  //     pm.expect(moment.duration(moment().diff(to.add(1, 'm'))).asSeconds()).to.lt(10); // first heartbeat is now minus 1 min minus some latency
  });
  */
}
