Modify sonarqube frontend plugin to call the new sonarqube backend

backend only have mock API for now

Signed-off-by: Neemys <36508659+Neemys@users.noreply.github.com>
This commit is contained in:
Neemys
2022-06-16 17:50:24 +02:00
parent 4d64f22c9d
commit 619b515172
6 changed files with 57 additions and 178 deletions
@@ -34,12 +34,18 @@ describe('createRouter', () => {
jest.resetAllMocks();
});
describe('GET /health', () => {
describe('GET /findings', () => {
it('returns ok', async () => {
const response = await request(app).get('/health');
const response = await request(app)
.get('/findings')
.set('componentKey', 'my:app')
.send();
expect(response.status).toEqual(200);
expect(response.body).toEqual({ status: 'ok' });
expect(response.body).toEqual({
analysisDate: '2022-10-22T04:55:23Z',
measures: [{ metric: 'coverage', value: '50' }],
});
});
});
});
@@ -30,10 +30,13 @@ export async function createRouter(
const router = Router();
router.use(express.json());
router.get('/health', (_, response) => {
logger.info('PONG!');
response.send({ status: 'ok' });
// mock api for now
router.get('/findings', (request, response) => {
logger.info(request.params);
response.send({
analysisDate: '2022-10-22T04:55:23Z',
measures: [{ metric: 'coverage', value: '50' }],
});
});
router.use(errorHandler());
return router;