function writeToResponseStream(chunks, stream, delay) {
  const writes = []
  for (const chunk of chunks) {
    const promise = new Promise(resolve => {
      setTimeout(() => {
        stream.write(chunk)
        resolve()
      }, delay)
    })
    writes.push(promise)
  }
  return Promise.all(writes)
}
Writes a set of messages to the provided response stream in a delayed
manner in order to simulate a long-running response stream.

@param {*[]} chunks Elements of a message to stream
@param {object} stream A Node writable stream, to simulate AWS's responseStream object
@param {number} delay A number of milliseconds to wait before writing each chunk to the stream

@returns {Promise} Promise to ensure completion of writes to a test response stream