test(catalog/gql): added some tests as i couldn't get codecov to ignore

This commit is contained in:
blam
2020-09-18 16:37:05 +02:00
parent 025795aeda
commit 2ed582f04a
4 changed files with 63 additions and 16 deletions
+18 -3
View File
@@ -13,10 +13,25 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import './router';
import { createRouter } from './router';
import supertest from 'supertest';
import { ConfigReader } from '@backstage/config';
import { createLogger } from 'winston';
import express from 'express';
describe('Router', () => {
it('should pass the test', () => {
expect(true).toBeTruthy();
describe('/health', () => {
it('should return ok', async () => {
const config = ConfigReader.fromConfigs([
{ data: { backend: { baseUrl: 'lol' } }, context: 'something' },
]);
const router = await createRouter({ config, logger: createLogger() });
const app = express().use(router);
const { body } = await supertest(app).get('/health');
expect(body).toEqual({ status: 'ok' });
});
});
});
+6 -6
View File
@@ -56,7 +56,11 @@ export async function createRouter(
const router = Router();
const apolloMiddlware = server.getMiddleware({ path: '/' });
router.get('/health', (_, response) => {
response.send({ status: 'ok' });
});
const apolloMiddleware = server.getMiddleware({ path: '/' });
if (process.env.NODE_ENV === 'development')
router.use(
@@ -67,11 +71,7 @@ export async function createRouter(
}),
);
router.use(apolloMiddlware);
router.get('/health', (_, response) => {
response.send({ status: 'ok' });
});
router.use(apolloMiddleware);
router.use(errorHandler());