-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6016a58
commit 112f191
Showing
7 changed files
with
439 additions
and
433 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
'use strict'; | ||
|
||
const got = require('got'); | ||
const express = require('express'); | ||
const { TestContext } = require('@terascope/job-components'); | ||
const { version } = require('../../package.json'); | ||
const { findPort } = require('../../lib/utils/port_utils'); | ||
const makeAPI = require('../../lib/cluster/services/api'); | ||
|
||
describe('HTTP API', () => { | ||
const app = express(); | ||
const assetsUrl = 'http://example.asset:1234'; | ||
const context = new TestContext('http-api'); | ||
context.services = { | ||
execution: { | ||
|
||
}, | ||
jobs: { | ||
|
||
} | ||
}; | ||
|
||
const stateStore = { | ||
|
||
}; | ||
|
||
let api; | ||
let port; | ||
let baseUrl; | ||
let server; | ||
|
||
beforeAll(async () => { | ||
port = await findPort(); | ||
|
||
baseUrl = `http://localhost:${port}`; | ||
|
||
api = await makeAPI(context, app, { assetsUrl, stateStore }); | ||
|
||
await new Promise((resolve, reject) => { | ||
server = app.listen(port, (err) => { | ||
if (err) reject(err); | ||
else resolve(); | ||
}); | ||
}); | ||
}); | ||
|
||
afterAll(async () => { | ||
if (api) { | ||
await api.shutdown(); | ||
} | ||
if (server) { | ||
await new Promise((resolve, reject) => { | ||
server.close((err) => { | ||
if (err) reject(err); | ||
else resolve(); | ||
}); | ||
}); | ||
} | ||
}); | ||
|
||
describe('GET /', () => { | ||
it('should the correct response', async () => { | ||
let response; | ||
|
||
try { | ||
response = await got('/', { baseUrl, json: true }); | ||
} catch (err) { | ||
expect(err.stack).toBeNil(); | ||
} | ||
|
||
expect(response.body).toMatchObject({ | ||
arch: context.arch, | ||
clustering_type: context.sysconfig.teraslice.cluster_manager_type, | ||
name: context.sysconfig.teraslice.name, | ||
node_version: process.version, | ||
platform: context.platform, | ||
teraslice_version: `v${version}` | ||
}); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.