close neo4j driver at the end of each test suite

This commit is contained in:
Moriz Wahl 2023-02-13 15:31:58 +01:00
parent 4390d72477
commit 7b3d530023
37 changed files with 42 additions and 15 deletions

View File

@ -33,6 +33,7 @@ beforeAll(async () => {
afterAll(async () => { afterAll(async () => {
await cleanDatabase() await cleanDatabase()
driver.close()
}) })
// TODO: avoid database clean after each test in the future if possible for performance and flakyness reasons by filling the database step by step, see issue https://github.com/Ocelot-Social-Community/Ocelot-Social/issues/4543 // TODO: avoid database clean after each test in the future if possible for performance and flakyness reasons by filling the database step by step, see issue https://github.com/Ocelot-Social-Community/Ocelot-Social/issues/4543

View File

@ -36,6 +36,7 @@ beforeAll(async () => {
afterAll(async () => { afterAll(async () => {
await cleanDatabase() await cleanDatabase()
driver.close()
}) })
// TODO: avoid database clean after each test in the future if possible for performance and flakyness reasons by filling the database step by step, see issue https://github.com/Ocelot-Social-Community/Ocelot-Social/issues/4543 // TODO: avoid database clean after each test in the future if possible for performance and flakyness reasons by filling the database step by step, see issue https://github.com/Ocelot-Social-Community/Ocelot-Social/issues/4543

View File

@ -50,6 +50,7 @@ beforeAll(async () => {
afterAll(async () => { afterAll(async () => {
await cleanDatabase() await cleanDatabase()
driver.close()
}) })
beforeEach(async () => { beforeEach(async () => {

View File

@ -80,14 +80,6 @@ const testEmailData = (emailTemplate, templateBuilder, templateData, texts) => {
return emailTemplate return emailTemplate
} }
// beforeAll(async () => {
// await cleanDatabase()
// })
// afterAll(async () => {
// await cleanDatabase()
// })
describe('templateBuilder', () => { describe('templateBuilder', () => {
describe('signupTemplate', () => { describe('signupTemplate', () => {
describe('multi language', () => { describe('multi language', () => {

View File

@ -28,6 +28,7 @@ beforeAll(async () => {
afterAll(async () => { afterAll(async () => {
await cleanDatabase() await cleanDatabase()
driver.close()
}) })
const createPostMutation = gql` const createPostMutation = gql`

View File

@ -56,6 +56,7 @@ beforeAll(async () => {
afterAll(async () => { afterAll(async () => {
await cleanDatabase() await cleanDatabase()
driver.close()
}) })
beforeEach(async () => { beforeEach(async () => {

View File

@ -24,6 +24,7 @@ beforeAll(async () => {
afterAll(async () => { afterAll(async () => {
await cleanDatabase() await cleanDatabase()
driver.close()
}) })
beforeEach(async () => { beforeEach(async () => {

View File

@ -28,6 +28,7 @@ describe('authorization', () => {
afterAll(async () => { afterAll(async () => {
await cleanDatabase() await cleanDatabase()
driver.close()
}) })
// TODO: avoid database clean after each test in the future if possible for performance and flakyness reasons by filling the database step by step, see issue https://github.com/Ocelot-Social-Community/Ocelot-Social/issues/4543 // TODO: avoid database clean after each test in the future if possible for performance and flakyness reasons by filling the database step by step, see issue https://github.com/Ocelot-Social-Community/Ocelot-Social/issues/4543

View File

@ -33,6 +33,7 @@ beforeAll(async () => {
afterAll(async () => { afterAll(async () => {
await cleanDatabase() await cleanDatabase()
driver.close()
}) })
beforeEach(async () => { beforeEach(async () => {
@ -152,7 +153,7 @@ describe('slugifyMiddleware', () => {
}) })
describe('but if the client specifies a slug', () => { describe('but if the client specifies a slug', () => {
it('rejects CreateGroup', async (done) => { it('rejects CreateGroup', async () => {
try { try {
await expect( await expect(
mutate({ mutate({
@ -171,7 +172,6 @@ describe('slugifyMiddleware', () => {
}, },
], ],
}) })
done()
} catch (error) { } catch (error) {
throw new Error(` throw new Error(`
${error} ${error}
@ -258,7 +258,7 @@ describe('slugifyMiddleware', () => {
}) })
describe('setting slug explicitly', () => { describe('setting slug explicitly', () => {
it('rejects UpdateGroup', async (done) => { it('rejects UpdateGroup', async () => {
try { try {
await expect( await expect(
mutate({ mutate({
@ -275,7 +275,6 @@ describe('slugifyMiddleware', () => {
}, },
], ],
}) })
done()
} catch (error) { } catch (error) {
throw new Error(` throw new Error(`
${error} ${error}
@ -382,7 +381,7 @@ describe('slugifyMiddleware', () => {
}) })
describe('but if the client specifies a slug', () => { describe('but if the client specifies a slug', () => {
it('rejects CreatePost', async (done) => { it('rejects CreatePost', async () => {
try { try {
await expect( await expect(
mutate({ mutate({
@ -402,7 +401,6 @@ describe('slugifyMiddleware', () => {
}, },
], ],
}) })
done()
} catch (error) { } catch (error) {
throw new Error(` throw new Error(`
${error} ${error}

View File

@ -195,6 +195,7 @@ beforeAll(async () => {
afterAll(async () => { afterAll(async () => {
await cleanDatabase() await cleanDatabase()
driver.close()
}) })
describe('softDeleteMiddleware', () => { describe('softDeleteMiddleware', () => {

View File

@ -42,6 +42,7 @@ beforeAll(async () => {
afterAll(async () => { afterAll(async () => {
await cleanDatabase() await cleanDatabase()
driver.close()
}) })
describe('middleware/userInteractions', () => { describe('middleware/userInteractions', () => {

View File

@ -75,6 +75,7 @@ beforeAll(async () => {
afterAll(async () => { afterAll(async () => {
await cleanDatabase() await cleanDatabase()
driver.close()
}) })
beforeEach(async () => { beforeEach(async () => {

View File

@ -25,6 +25,7 @@ beforeAll(async () => {
afterAll(async () => { afterAll(async () => {
await cleanDatabase() await cleanDatabase()
driver.close()
}) })
beforeEach(async () => { beforeEach(async () => {

View File

@ -37,6 +37,7 @@ beforeAll(async () => {
afterAll(async () => { afterAll(async () => {
await cleanDatabase() await cleanDatabase()
driver.close()
}) })
describe('donations', () => { describe('donations', () => {

View File

@ -30,6 +30,7 @@ beforeAll(async () => {
afterAll(async () => { afterAll(async () => {
await cleanDatabase() await cleanDatabase()
driver.close()
}) })
beforeEach(async () => { beforeEach(async () => {

View File

@ -71,6 +71,7 @@ beforeAll(async () => {
afterAll(async () => { afterAll(async () => {
await cleanDatabase() await cleanDatabase()
driver.close()
}) })
beforeEach(async () => { beforeEach(async () => {

View File

@ -252,6 +252,7 @@ beforeAll(async () => {
afterAll(async () => { afterAll(async () => {
await cleanDatabase() await cleanDatabase()
driver.close()
}) })
describe('in mode', () => { describe('in mode', () => {

View File

@ -15,6 +15,7 @@ beforeAll(async () => {
afterAll(async () => { afterAll(async () => {
await cleanDatabase() await cleanDatabase()
driver.close()
}) })
beforeEach(async () => { beforeEach(async () => {

View File

@ -52,6 +52,7 @@ beforeAll(async () => {
afterAll(async () => { afterAll(async () => {
await cleanDatabase() await cleanDatabase()
driver.close()
}) })
describe('inviteCodes', () => { describe('inviteCodes', () => {

View File

@ -26,6 +26,7 @@ beforeAll(async () => {
afterAll(async () => { afterAll(async () => {
await cleanDatabase() await cleanDatabase()
driver.close()
}) })
// TODO: avoid database clean after each test in the future if possible for performance and flakyness reasons by filling the database step by step, see issue https://github.com/Ocelot-Social-Community/Ocelot-Social/issues/4543 // TODO: avoid database clean after each test in the future if possible for performance and flakyness reasons by filling the database step by step, see issue https://github.com/Ocelot-Social-Community/Ocelot-Social/issues/4543

View File

@ -70,6 +70,7 @@ describe('moderate resources', () => {
afterAll(async () => { afterAll(async () => {
await cleanDatabase() await cleanDatabase()
driver.close()
}) })
beforeEach(async () => { beforeEach(async () => {

View File

@ -29,6 +29,7 @@ beforeAll(async () => {
afterAll(async () => { afterAll(async () => {
await cleanDatabase() await cleanDatabase()
driver.close()
}) })
beforeEach(async () => { beforeEach(async () => {

View File

@ -38,6 +38,7 @@ beforeAll(async () => {
afterAll(async () => { afterAll(async () => {
await cleanDatabase() await cleanDatabase()
driver.close()
}) })
beforeEach(() => { beforeEach(() => {

View File

@ -56,6 +56,7 @@ beforeAll(async () => {
afterAll(async () => { afterAll(async () => {
await cleanDatabase() await cleanDatabase()
driver.close()
}) })
beforeEach(async () => { beforeEach(async () => {

View File

@ -61,6 +61,7 @@ beforeAll(async () => {
afterAll(async () => { afterAll(async () => {
await cleanDatabase() await cleanDatabase()
driver.close()
}) })
describe('Posts in Groups', () => { describe('Posts in Groups', () => {

View File

@ -29,6 +29,7 @@ beforeAll(async () => {
afterAll(async () => { afterAll(async () => {
await cleanDatabase() await cleanDatabase()
driver.close()
}) })
beforeEach(async () => { beforeEach(async () => {

View File

@ -117,6 +117,7 @@ describe('file a report on a resource', () => {
afterAll(async () => { afterAll(async () => {
await cleanDatabase() await cleanDatabase()
driver.close()
}) })
// TODO: avoid database clean after each test in the future if possible for performance and flakyness reasons by filling the database step by step, see issue https://github.com/Ocelot-Social-Community/Ocelot-Social/issues/4543 // TODO: avoid database clean after each test in the future if possible for performance and flakyness reasons by filling the database step by step, see issue https://github.com/Ocelot-Social-Community/Ocelot-Social/issues/4543

View File

@ -26,6 +26,7 @@ beforeAll(async () => {
afterAll(async () => { afterAll(async () => {
await cleanDatabase() await cleanDatabase()
driver.close()
}) })
const searchQuery = gql` const searchQuery = gql`

View File

@ -51,6 +51,7 @@ describe('shout and unshout posts', () => {
afterAll(async () => { afterAll(async () => {
await cleanDatabase() await cleanDatabase()
driver.close()
}) })
beforeEach(async () => { beforeEach(async () => {

View File

@ -12,6 +12,7 @@ beforeAll(async () => {
afterAll(async () => { afterAll(async () => {
await cleanDatabase() await cleanDatabase()
driver.close()
}) })
describe('SocialMedia', () => { describe('SocialMedia', () => {

View File

@ -39,6 +39,7 @@ beforeAll(async () => {
afterAll(async () => { afterAll(async () => {
await cleanDatabase() await cleanDatabase()
driver.close()
}) })
// TODO: avoid database clean after each test in the future if possible for performance and flakyness reasons by filling the database step by step, see issue https://github.com/Ocelot-Social-Community/Ocelot-Social/issues/4543 // TODO: avoid database clean after each test in the future if possible for performance and flakyness reasons by filling the database step by step, see issue https://github.com/Ocelot-Social-Community/Ocelot-Social/issues/4543

View File

@ -60,6 +60,7 @@ beforeAll(async () => {
afterAll(async () => { afterAll(async () => {
await cleanDatabase() await cleanDatabase()
driver.close()
}) })
describe('resolvers/userData', () => { describe('resolvers/userData', () => {

View File

@ -6,10 +6,12 @@ import { loginMutation } from '../../graphql/userManagement'
import { createTestClient } from 'apollo-server-testing' import { createTestClient } from 'apollo-server-testing'
import createServer, { context } from '../../server' import createServer, { context } from '../../server'
import encode from '../../jwt/encode' import encode from '../../jwt/encode'
import { getNeode } from '../../db/neo4j' import { getNeode, getDriver } from '../../db/neo4j'
import { categories } from '../../constants/categories' import { categories } from '../../constants/categories'
const neode = getNeode() const neode = getNeode()
const driver = getDriver()
let query, mutate, variables, req, user let query, mutate, variables, req, user
const disable = async (id) => { const disable = async (id) => {
@ -47,6 +49,7 @@ beforeAll(async () => {
afterAll(async () => { afterAll(async () => {
await cleanDatabase() await cleanDatabase()
driver.close()
}) })
beforeEach(() => { beforeEach(() => {

View File

@ -81,6 +81,7 @@ beforeAll(async () => {
afterAll(async () => { afterAll(async () => {
await cleanDatabase() await cleanDatabase()
driver.close()
}) })
// TODO: avoid database clean after each test in the future if possible for performance and flakyness reasons by filling the database step by step, see issue https://github.com/Ocelot-Social-Community/Ocelot-Social/issues/4543 // TODO: avoid database clean after each test in the future if possible for performance and flakyness reasons by filling the database step by step, see issue https://github.com/Ocelot-Social-Community/Ocelot-Social/issues/4543

View File

@ -90,6 +90,7 @@ beforeAll(async () => {
afterAll(async () => { afterAll(async () => {
await cleanDatabase() await cleanDatabase()
driver.close()
}) })
beforeEach(() => { beforeEach(() => {

View File

@ -18,6 +18,7 @@ beforeAll(async () => {
afterAll(async () => { afterAll(async () => {
await cleanDatabase() await cleanDatabase()
driver.close()
}) })
beforeEach(() => { beforeEach(() => {

View File

@ -28,6 +28,7 @@ beforeAll(async () => {
afterAll(async () => { afterAll(async () => {
await cleanDatabase() await cleanDatabase()
driver.close()
}) })
describe('count post teaser views', () => { describe('count post teaser views', () => {