Docs for testing the API (#10275)

* mock-knex

* test on the migrations run started.

* test passing for run.up()

* reorganize /tests/ to allow integration tests

* e2e setup changes

* e2e jest.config moved

* e2e paths fixed, integration config

* add nonadmin role and user seed+migration

* auth/login w/ documentation (docs will be moved)

* update user seed

* add postgres10 to the ci?

* argon2 saves the day

* items tests passing with postgres10 support

* removed comments

* move generateHash out of directus_users

Co-authored-by: Jay Cammarano <jaycammarano@gmail.com>
This commit is contained in:
Jay Cammarano
2021-12-10 14:58:51 -05:00
committed by GitHub
parent f6264371ef
commit 00a838f020
32 changed files with 354 additions and 93 deletions

View File

@@ -0,0 +1,28 @@
import knex, { Knex } from 'knex';
import { getTracker, MockClient, Tracker } from 'knex-mock-client';
import run from '../../../database/migrations/run';
describe('run', () => {
let db: jest.Mocked<Knex>;
let tracker: Tracker;
beforeAll(() => {
db = knex({ client: MockClient }) as jest.Mocked<Knex>;
tracker = getTracker();
});
afterEach(() => {
tracker.reset();
});
describe('when passed the argument up', () => {
it('returns "Nothing To Updage" if no directus_migrations', async () => {
// note the difference between an empty array and ['Empty']
tracker.on.select('directus_migrations').response(['Empty']);
await run(db, 'up').catch((e: Error) => {
expect(e).toBeInstanceOf(Error);
expect(e.message).toBe('Nothing to upgrade');
});
});
});
});