mirror of
https://github.com/directus/directus.git
synced 2026-02-12 06:24:54 -05:00
* Change license to BSL1.1 * Mark major version * Fix formatting * Remove duplicate heading * Update formatting * Copy paste error * Update license * Update license * Format covenants * Update readme.md * Update licenses for packages * Update readme.md * Update contributors.yml OG... but to be clear, rijkvanzanten is the one who really built all of this ❤️ * Tweak license in openapi * Update packages/specs/src/openapi.yaml * Add MIT license headers * Use v10 in examples * Update additional examples * Update generate-extensions-entrypoint.test.ts * Update tests to use latest v9 and v10 versions * use lowercase for naming consistency * change casing for api license * Update migrations doc * Update dictionary * Consistent ordering of license field in app/package.json * Use major version in specs again (but as string) So it's valid for all v10 versions * Consolidate readme's --------- Co-authored-by: Ben Haynes <ben@directus.io> Co-authored-by: Pascal Jufer <pascal-jufer@bluewin.ch> Co-authored-by: ian <licitdev@gmail.com> Co-authored-by: Azri Kahar <42867097+azrikahar@users.noreply.github.com>
56 lines
1.8 KiB
TypeScript
56 lines
1.8 KiB
TypeScript
import { describe, expect, test, vi } from 'vitest';
|
|
import type { Snapshot } from '../types/snapshot.js';
|
|
import { validateSnapshot } from './validate-snapshot.js';
|
|
|
|
vi.mock('./package.js', () => ({
|
|
version: '10.0.0',
|
|
}));
|
|
|
|
vi.mock('../database/index.js', () => ({
|
|
getDatabaseClient: () => 'sqlite',
|
|
}));
|
|
|
|
describe('should fail on invalid snapshot schema', () => {
|
|
test('empty snapshot', () => {
|
|
const snapshot = {} as Snapshot;
|
|
|
|
expect(() => validateSnapshot(snapshot)).toThrowError('"version" is required');
|
|
});
|
|
|
|
test('invalid version', () => {
|
|
const snapshot = { version: 0 } as Snapshot;
|
|
|
|
expect(() => validateSnapshot(snapshot)).toThrowError('"version" must be [1]');
|
|
});
|
|
|
|
test('invalid schema', () => {
|
|
const snapshot = { version: 1, directus: '10.0.0', collections: {} } as Snapshot;
|
|
|
|
expect(() => validateSnapshot(snapshot)).toThrowError('"collections" must be an array');
|
|
});
|
|
});
|
|
|
|
describe('should require force option on version / vendor mismatch', () => {
|
|
test('directus version mismatch', () => {
|
|
const snapshot = { version: 1, directus: '9.26.0' } as Snapshot;
|
|
|
|
expect(() => validateSnapshot(snapshot)).toThrowError(
|
|
"Provided snapshot's directus version 9.26.0 does not match the current instance's version 10.0.0"
|
|
);
|
|
});
|
|
|
|
test('db vendor mismatch', () => {
|
|
const snapshot = { version: 1, directus: '10.0.0', vendor: 'postgres' } as Snapshot;
|
|
|
|
expect(() => validateSnapshot(snapshot)).toThrowError(
|
|
"Provided snapshot's vendor postgres does not match the current instance's vendor sqlite."
|
|
);
|
|
});
|
|
});
|
|
|
|
test('should allow bypass on version / vendor mismatch via force option ', () => {
|
|
const snapshot = { version: 1, directus: '9.26.0', vendor: 'postgres' } as Snapshot;
|
|
|
|
expect(validateSnapshot(snapshot, true)).toBeUndefined();
|
|
});
|