-import * as express from 'express'
+import express from 'express'
+import { Server } from 'http'
import { randomInt } from '@shared/core-utils'
+import { terminateServer } from './utils'
export class MockInstancesIndex {
+ private server: Server
+
private readonly indexInstances: { host: string, createdAt: string }[] = []
initialize () {
})
})
- const port = 42101 + randomInt(1, 100)
- app.listen(port, () => res(port))
+ const port = 42000 + randomInt(1, 1000)
+ this.server = app.listen(port, () => res(port))
})
}
addInstance (host: string) {
this.indexInstances.push({ host, createdAt: new Date().toISOString() })
}
+
+ terminate () {
+ return terminateServer(this.server)
+ }
}