test(catalog/gql): added some tests as i couldn't get codecov to ignore
This commit is contained in:
@@ -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' });
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -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());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user