From 35ecc1b9dce25f702d17e606dea3e47b20c5f795 Mon Sep 17 00:00:00 2001 From: junha-ahn Date: Wed, 18 Oct 2023 16:25:06 +0900 Subject: [PATCH] feat: add job js --- src/job.js | 14 +++++++++++++ test/integrationTest/job/job.spec.js | 31 ++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 src/job.js create mode 100644 test/integrationTest/job/job.spec.js diff --git a/src/job.js b/src/job.js new file mode 100644 index 0000000..e825622 --- /dev/null +++ b/src/job.js @@ -0,0 +1,14 @@ +const config = require('./config') +const Logger = $require('loaders/logger') + +async function start() { + await $require('loaders')() + + Logger.info(` + 🛡️ Job Started 🛡️ + `) + + module.exports = app +} + +start() diff --git a/test/integrationTest/job/job.spec.js b/test/integrationTest/job/job.spec.js new file mode 100644 index 0000000..4d600e6 --- /dev/null +++ b/test/integrationTest/job/job.spec.js @@ -0,0 +1,31 @@ +const chai = require('chai') +const chaiHttp = require('chai-http') +const { GenericContainer } = require('testcontainers') +const expect = chai.expect +chai.use(chaiHttp) + +describe('Ticket', () => { + let server = null + let redis = null + let ticketStoreService = null + + beforeAll(async () => { + container = await new GenericContainer('redis') + .withExposedPorts(6379) + .start() + process.env = { + NODE_ENV: 'test', + REDIS_HOST: container.getHost(), + REDIS_PORT: container.getMappedPort(6379), + } + + server = require('../../../src/api') + redis = $require('loaders/redis') + const TicketStoreService = $require('services/ticketStore') + ticketStoreService = new TicketStoreService(redis) + }) + + beforeEach(async () => { + await redis.flushAll() + }) +})