Added get runners by team test
All checks were successful
continuous-integration/drone/pr Build is passing
All checks were successful
continuous-integration/drone/pr Build is passing
ref #125
This commit is contained in:
parent
f71a22f4dd
commit
69417e93c0
@ -33,38 +33,62 @@ describe('GET /api/runners after adding', () => {
|
|||||||
let added_org_id;
|
let added_org_id;
|
||||||
let added_runner;
|
let added_runner;
|
||||||
it('creating a new org with just a name should return 200', async () => {
|
it('creating a new org with just a name should return 200', async () => {
|
||||||
const res1 = await axios.post(base + '/api/organizations', {
|
const res = await axios.post(base + '/api/organizations', {
|
||||||
"name": "test123"
|
"name": "test123"
|
||||||
}, axios_config);
|
}, axios_config);
|
||||||
let added_org = res1.data
|
let added_org = res.data
|
||||||
added_org_id = added_org.id;
|
added_org_id = added_org.id;
|
||||||
expect(res1.status).toEqual(200);
|
expect(res.status).toEqual(200);
|
||||||
expect(res1.headers['content-type']).toContain("application/json")
|
expect(res.headers['content-type']).toContain("application/json")
|
||||||
});
|
});
|
||||||
it('creating a new runner with only needed params should return 200', async () => {
|
it('creating a new runner with only needed params should return 200', async () => {
|
||||||
const res2 = await axios.post(base + '/api/runners', {
|
const res = await axios.post(base + '/api/runners', {
|
||||||
"firstname": "first",
|
"firstname": "first",
|
||||||
"lastname": "last",
|
"lastname": "last",
|
||||||
"group": added_org_id
|
"group": added_org_id
|
||||||
}, axios_config);
|
}, axios_config);
|
||||||
added_runner = res2.data;
|
added_runner = res.data;
|
||||||
expect(res2.status).toEqual(200);
|
expect(res.status).toEqual(200);
|
||||||
expect(res2.headers['content-type']).toContain("application/json")
|
expect(res.headers['content-type']).toContain("application/json")
|
||||||
});
|
});
|
||||||
it('explicit get should return 200', async () => {
|
it('explicit get should return 200', async () => {
|
||||||
const res3 = await axios.get(base + '/api/runners/' + added_runner.id, axios_config);
|
const res = await axios.get(base + '/api/runners/' + added_runner.id, axios_config);
|
||||||
expect(res3.status).toEqual(200);
|
expect(res.status).toEqual(200);
|
||||||
expect(res3.headers['content-type']).toContain("application/json")
|
expect(res.headers['content-type']).toContain("application/json")
|
||||||
let gotten_runner = res3.data
|
let gotten_runner = res.data
|
||||||
expect(gotten_runner).toEqual(added_runner);
|
expect(gotten_runner).toEqual(added_runner);
|
||||||
});
|
});
|
||||||
it('get from all runners should return 200', async () => {
|
it('get from all runners should return 200', async () => {
|
||||||
const res4 = await axios.get(base + '/api/runners/', axios_config);
|
const res = await axios.get(base + '/api/runners/', axios_config);
|
||||||
expect(res4.status).toEqual(200);
|
expect(res.status).toEqual(200);
|
||||||
expect(res4.headers['content-type']).toContain("application/json")
|
expect(res.headers['content-type']).toContain("application/json")
|
||||||
let gotten_runners = res4.data
|
let gotten_runners = res.data
|
||||||
expect(gotten_runners).toContainEqual(added_runner);
|
expect(gotten_runners).toContainEqual(added_runner);
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
// ---------------
|
||||||
|
describe('GET /api/organizations/:id/runners after adding', () => {
|
||||||
|
let added_org_id;
|
||||||
|
let added_runner;
|
||||||
|
it('creating a new org with just a name should return 200', async () => {
|
||||||
|
const res = await axios.post(base + '/api/organizations', {
|
||||||
|
"name": "test123"
|
||||||
|
}, axios_config);
|
||||||
|
let added_org = res.data
|
||||||
|
added_org_id = added_org.id;
|
||||||
|
expect(res.status).toEqual(200);
|
||||||
|
expect(res.headers['content-type']).toContain("application/json")
|
||||||
|
});
|
||||||
|
it('creating a new runner with only needed params should return 200', async () => {
|
||||||
|
const res = await axios.post(base + '/api/runners', {
|
||||||
|
"firstname": "first",
|
||||||
|
"lastname": "last",
|
||||||
|
"group": added_org_id
|
||||||
|
}, axios_config);
|
||||||
|
added_runner = res.data;
|
||||||
|
expect(res.status).toEqual(200);
|
||||||
|
expect(res.headers['content-type']).toContain("application/json")
|
||||||
|
});
|
||||||
it('check if scans was added via the orgs/runners endpoint.', async () => {
|
it('check if scans was added via the orgs/runners endpoint.', async () => {
|
||||||
const res = await axios.get(base + '/api/organizations/' + added_org_id + "/runners", axios_config);
|
const res = await axios.get(base + '/api/organizations/' + added_org_id + "/runners", axios_config);
|
||||||
expect(res.status).toEqual(200);
|
expect(res.status).toEqual(200);
|
||||||
@ -72,3 +96,43 @@ describe('GET /api/runners after adding', () => {
|
|||||||
expect(res.data).toContainEqual(added_runner);
|
expect(res.data).toContainEqual(added_runner);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
// ---------------
|
||||||
|
describe('GET /api/teams/:id/runners after adding', () => {
|
||||||
|
let added_org_id;
|
||||||
|
let added_team;
|
||||||
|
let added_runner;
|
||||||
|
it('creating a new org with just a name should return 200', async () => {
|
||||||
|
const res = await axios.post(base + '/api/organizations', {
|
||||||
|
"name": "test123"
|
||||||
|
}, axios_config);
|
||||||
|
let added_org = res.data
|
||||||
|
added_org_id = added_org.id;
|
||||||
|
expect(res.status).toEqual(200);
|
||||||
|
expect(res.headers['content-type']).toContain("application/json")
|
||||||
|
});
|
||||||
|
it('creating a new team with a parent org should return 200', async () => {
|
||||||
|
const res = await axios.post(base + '/api/teams', {
|
||||||
|
"name": "test_team",
|
||||||
|
"parentGroup": added_org_id
|
||||||
|
}, axios_config);
|
||||||
|
added_team = res.data;
|
||||||
|
expect(res.status).toEqual(200);
|
||||||
|
expect(res.headers['content-type']).toContain("application/json")
|
||||||
|
});
|
||||||
|
it('creating a new runner with only needed params should return 200', async () => {
|
||||||
|
const res = await axios.post(base + '/api/runners', {
|
||||||
|
"firstname": "first",
|
||||||
|
"lastname": "last",
|
||||||
|
"group": added_team.id
|
||||||
|
}, axios_config);
|
||||||
|
added_runner = res.data;
|
||||||
|
expect(res.status).toEqual(200);
|
||||||
|
expect(res.headers['content-type']).toContain("application/json")
|
||||||
|
});
|
||||||
|
it('check if scans was added via the orgs/runners endpoint.', async () => {
|
||||||
|
const res = await axios.get(base + '/api/teams/' + added_team.id + "/runners", axios_config);
|
||||||
|
expect(res.status).toEqual(200);
|
||||||
|
expect(res.headers['content-type']).toContain("application/json");
|
||||||
|
expect(res.data).toContainEqual(added_runner);
|
||||||
|
});
|
||||||
|
});
|
Loading…
x
Reference in New Issue
Block a user