Skip to content

Commit a86f456

Browse files
authored
[O2B-805] Fix broken FLP API tests and remove unutilized and broken FLP Log implementation (#1282)
* refactor: remove unutilized and broken FLP Log Implementation * refactor: remove test cases for non-existent functionality and fix broken test cases * include FLP API tests in the API test suites
1 parent 3d95551 commit a86f456

8 files changed

Lines changed: 5 additions & 258 deletions

File tree

lib/server/controllers/flps.controller.js

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ const {
1515
flp: {
1616
GetAllFlpsUseCase,
1717
GetFlpUseCase,
18-
GetLogsByFlpUseCase,
1918
CreateFlpUseCase,
2019
UpdateFlpUseCase,
2120
},
@@ -97,40 +96,6 @@ const getFlpById = async (request, response) => {
9796
}
9897
};
9998

100-
/**
101-
* Get all logs with flp.
102-
*
103-
* @param {Object} request The *request* object represents the HTTP request and has properties for the request query
104-
* string, parameters, body, HTTP headers, and so on.
105-
* @param {Object} response The *response* object represents the HTTP response that an Express app sends when it gets an
106-
* HTTP request.
107-
* @returns {undefined}
108-
*/
109-
const getLogsByFlpId = async (request, response) => {
110-
const value = await dtoValidator(GetFlpDto, request, response);
111-
if (!value) {
112-
return;
113-
}
114-
115-
const logs = await new GetLogsByFlpUseCase()
116-
.execute(value);
117-
118-
if (logs === null) {
119-
response.status(404).json({
120-
errors: [
121-
{
122-
status: '404',
123-
title: `Flp with this id (${value.params.flpId}) could not be found`,
124-
},
125-
],
126-
});
127-
} else {
128-
response.status(200).json({
129-
data: logs,
130-
});
131-
}
132-
};
133-
13499
/**
135100
* Create a new flp.
136101
*
@@ -184,7 +149,6 @@ const update = async (request, response) => {
184149
module.exports = {
185150
getFlpById,
186151
listFlps,
187-
getLogsByFlpId,
188152
create,
189153
update,
190154
};

lib/server/routers/flps.router.js

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,6 @@ module.exports = {
2323
method: 'get',
2424
path: ':flpId',
2525
controller: FlpsController.getFlpById,
26-
children: [
27-
{
28-
method: 'get',
29-
path: 'logs',
30-
controller: FlpsController.getLogsByFlpId,
31-
},
32-
],
3326
},
3427
{
3528
method: 'post',

lib/usecases/flp/GetLogsByFlpUseCase.js

Lines changed: 0 additions & 56 deletions
This file was deleted.

lib/usecases/flp/index.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,12 @@
1313

1414
const GetAllFlpsUseCase = require('./GetAllFlpsUseCase');
1515
const GetFlpUseCase = require('./GetFlpUseCase');
16-
const GetLogsByFlpUseCase = require('./GetLogsByFlpUseCase');
1716
const CreateFlpUseCase = require('./CreateFlpUseCase');
1817
const UpdateFlpUseCase = require('./UpdateFlpUseCase');
1918

2019
module.exports = {
2120
GetAllFlpsUseCase,
2221
GetFlpUseCase,
23-
GetLogsByFlpUseCase,
2422
CreateFlpUseCase,
2523
UpdateFlpUseCase,
2624
};

test/api/flps.test.js

Lines changed: 3 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,7 @@ module.exports = () => {
8484

8585
const { errors } = res.body;
8686
const titleError = errors.find((err) => err.source.pointer === '/data/attributes/query/page/limit');
87-
expect(titleError.detail).to.equal('"query.page.limit" must be larger than or equal to 1');
88-
87+
expect(titleError.detail).to.equal('"query.page.limit" must be greater than or equal to 1');
8988
done();
9089
});
9190
});
@@ -109,40 +108,6 @@ module.exports = () => {
109108
done();
110109
});
111110
});
112-
113-
it('should support sorting, name DESC', (done) => {
114-
request(server)
115-
.get('/api/flps?sort[name]=desc')
116-
.expect(200)
117-
.end((err, res) => {
118-
if (err) {
119-
done(err);
120-
return;
121-
}
122-
123-
const { data } = res.body;
124-
expect(data[0].name).to.be.greaterThan(data[1].name);
125-
126-
done();
127-
});
128-
});
129-
130-
it('should support sorting, name ASC', (done) => {
131-
request(server)
132-
.get('/api/flps?sort[name]=asc')
133-
.expect(200)
134-
.end((err, res) => {
135-
if (err) {
136-
done(err);
137-
return;
138-
}
139-
140-
const { data } = res.body;
141-
expect(data[1].name).to.be.greaterThan(data[0].name);
142-
143-
done();
144-
});
145-
});
146111
});
147112

148113
describe('GET /api/flps/:flpId', () => {
@@ -233,65 +198,6 @@ module.exports = () => {
233198
});
234199
});
235200

236-
describe('GET /api/flps/:flpId/logs', () => {
237-
it('should return 400 if the flp id is not a number', (done) => {
238-
request(server)
239-
.get('/api/flps/abc/logs')
240-
.expect(400)
241-
.end((err, res) => {
242-
if (err) {
243-
done(err);
244-
return;
245-
}
246-
247-
const { errors } = res.body;
248-
const titleError = errors.find((err) => err.source.pointer === '/data/attributes/params/flpId');
249-
expect(titleError.detail).to.equal('"params.flpId" must be a number');
250-
251-
done();
252-
});
253-
});
254-
255-
it('should return 404 if the flp could not be found', (done) => {
256-
request(server)
257-
.get('/api/flps/999999999/logs')
258-
.expect(404)
259-
.end((err, res) => {
260-
if (err) {
261-
done(err);
262-
return;
263-
}
264-
265-
expect(res.body.errors[0].title).to.equal('Flp with this id (999999999) could not be found');
266-
267-
done();
268-
});
269-
});
270-
271-
it('should return 200 in all other cases', (done) => {
272-
request(server)
273-
.get('/api/flps/1/logs')
274-
.expect(200)
275-
.end((err, res) => {
276-
if (err) {
277-
done(err);
278-
return;
279-
}
280-
281-
expect(res.body.data).to.be.an('array');
282-
expect(res.body.data).to.have.lengthOf(4);
283-
284-
expect(res.body.data[0].id).to.equal(1);
285-
expect(res.body.data[0].flps).to.deep.equal([
286-
{
287-
id: 1,
288-
},
289-
]);
290-
done();
291-
});
292-
});
293-
});
294-
295201
describe('POST api/flps', () => {
296202
it('should return 400 if no name or hostname is provided', (done) => {
297203
request(server)
@@ -320,6 +226,7 @@ module.exports = () => {
320226
.send({
321227
name: 'FLPIEE',
322228
hostname: 'www.home.cern',
229+
runNumber: 106,
323230
})
324231
.expect(201)
325232
.end((err, res) => {
@@ -330,6 +237,7 @@ module.exports = () => {
330237

331238
expect(res.body.data.name).to.equal('FLPIEE');
332239
expect(res.body.data.hostname).to.equal('www.home.cern');
240+
expect(res.body.data.runNumber).to.equal(106);
333241

334242
done();
335243
});

test/api/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const DetectorsSuite = require('./detectors.test.js');
1717
const DPLProcessSuite = require('./dplProcess.test.js');
1818
const EnvironmentsSuite = require('./environments.test.js');
1919
const EosReportSuite = require('./eosReport.test.js');
20-
// TODO [O2B-805] const FlpSuite = require('./flps.test.js');
20+
const FlpSuite = require('./flps.test.js');
2121
const StatusSuite = require('./status.test.js');
2222
const LogsSuite = require('./logs.test.js');
2323
const LhcFillSuite = require('./lhcFills.test.js');
@@ -37,7 +37,7 @@ module.exports = () => {
3737
describe('DPL Process API', DPLProcessSuite);
3838
describe('Environments API', EnvironmentsSuite);
3939
describe('EOS report API', EosReportSuite);
40-
// TODO [O2B-805] describe('FLP API', FlpSuite);
40+
describe('FLP API', FlpSuite);
4141
describe('LhcFills API', LhcFillSuite);
4242
describe('Logs API', LogsSuite);
4343
describe('Runs API', RunsSuite);

test/lib/usecases/flp/GetAllFlpsUseCase.test.js

Lines changed: 0 additions & 58 deletions
This file was deleted.

test/lib/usecases/flp/index.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,9 @@
1212
*/
1313

1414
const CreateFlpUseCase = require('./CreateFlpUseCase.test.js');
15-
const GetAllFlpsUseCase = require('./GetAllFlpsUseCase.test.js');
1615
const GetFlpUseCase = require('./GetFlpUseCase.test.js');
1716

1817
module.exports = () => {
1918
describe('CreateFlpUseCase', CreateFlpUseCase);
20-
describe('GetAllFlpsUseCase', GetAllFlpsUseCase);
2119
describe('GetFlpUseCase', GetFlpUseCase);
2220
};

0 commit comments

Comments
 (0)