Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
public async getRunningKernels(): Promise {
const models = await Kernel.listRunning(this.serverSettings);
// Remove duplicates.
const dup = new Set();
return models
.map(m => {
return {
id: m.id,
name: m.name,
lastActivityTime: m.last_activity ? new Date(Date.parse(m.last_activity.toString())) : new Date(),
numberOfConnections: m.connections ? parseInt(m.connections.toString(), 10) : 0
};
})
.filter(item => {
if (dup.has(item.id)) {
return false;
}
dup.add(item.id);
it('should accept server settings', async () => {
const serverSettings = makeSettings();
const kernel = await Kernel.startNew({ serverSettings });
const response = await Kernel.listRunning(serverSettings);
expect(toArray(response).length).to.be.greaterThan(0);
await kernel.shutdown();
});
it('should throw an error for an error response', async () => {
const settings = getRequestHandler(500, {});
const promise = Kernel.listRunning(settings);
await expectFailure(promise, '');
});
});
it('should yield a list of valid kernel ids', async () => {
const response = await Kernel.listRunning();
expect(toArray(response).length).to.be.greaterThan(0);
});
it('should yield a list of valid kernel ids', async () => {
const response = await Kernel.listRunning();
expect(toArray(response).length).to.be.greaterThan(0);
});
it('should accept server settings', async () => {
const serverSettings = makeSettings();
const kernel = await Kernel.startNew({ serverSettings });
const response = await Kernel.listRunning(serverSettings);
expect(toArray(response).length).to.be.greaterThan(0);
await kernel.shutdown();
});
it('should throw an error for an error response', async () => {
const settings = getRequestHandler(500, {});
const promise = Kernel.listRunning(settings);
await expectFailure(promise, '');
});
});
it('should accept server settings', async () => {
const serverSettings = makeSettings();
const kernel = await Kernel.startNew({ serverSettings });
const response = await Kernel.listRunning(serverSettings);
expect(toArray(response).length).to.be.greaterThan(0);
await kernel.shutdown();
});
it('should yield a list of valid kernel ids', async () => {
const response = await Kernel.listRunning();
expect(toArray(response).length).to.be.greaterThan(0);
});
it('should throw an error for an error response', async () => {
const settings = getRequestHandler(500, {});
const promise = Kernel.listRunning(settings);
await expectFailure(promise, '');
});
});