chore: Add more integration tests for create/update/delete in CLI
parent
a4b767f412
commit
dd6e2f6c81
|
@ -13,20 +13,41 @@ describe('Test the config-sync CLI', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Export', async () => {
|
test('Export', async () => {
|
||||||
const { stdout } = await exec('yarn cs export -y');
|
const { stdout: exportOutput } = await exec('yarn cs export -y');
|
||||||
expect(stdout).toContain('Finished export');
|
expect(exportOutput).toContain('Finished export');
|
||||||
|
const { stdout: diffOutput } = await exec('yarn cs diff');
|
||||||
|
expect(diffOutput).toContain('No differences between DB and sync directory');
|
||||||
});
|
});
|
||||||
test('Import', async () => {
|
|
||||||
await exec('rm -rf config/sync/admin-role.strapi-editor.json');
|
test('Import (delete)', async () => {
|
||||||
const { stdout } = await exec('yarn cs import -y');
|
// Remove a file to trigger a delete.
|
||||||
expect(stdout).toContain('Finished import');
|
await exec('mv config/sync/admin-role.strapi-editor.json .tmp');
|
||||||
|
const { stdout: importOutput } = await exec('yarn cs import -y');
|
||||||
|
expect(importOutput).toContain('Finished import');
|
||||||
|
const { stdout: diffOutput } = await exec('yarn cs diff');
|
||||||
|
expect(diffOutput).toContain('No differences between DB and sync directory');
|
||||||
});
|
});
|
||||||
test('Diff', async () => {
|
test('Import (update)', async () => {
|
||||||
const { stdout } = await exec('yarn cs diff');
|
// Update a core-store file.
|
||||||
expect(stdout).toContain('No differences between DB and sync directory');
|
await exec('sed -i \'s/"description":"",/"description":"test",/g\' config/sync/core-store.plugin_content_manager_configuration_content_types##plugin##users-permissions.user.json');
|
||||||
|
// Update a file that has relations.
|
||||||
|
await exec('sed -i \'s/{"action":"plugin::users-permissions.auth.register"},//g\' config/sync/user-role.public.json');
|
||||||
|
const { stdout: importOutput } = await exec('yarn cs import -y');
|
||||||
|
expect(importOutput).toContain('Finished import');
|
||||||
|
const { stdout: diffOutput } = await exec('yarn cs diff');
|
||||||
|
expect(diffOutput).toContain('No differences between DB and sync directory');
|
||||||
});
|
});
|
||||||
|
test('Import (create)', async () => {
|
||||||
|
// Add a file to trigger a creation.
|
||||||
|
await exec('mv .tmp/admin-role.strapi-editor.json config/sync/');
|
||||||
|
const { stdout: importOutput } = await exec('yarn cs import -y');
|
||||||
|
expect(importOutput).toContain('Finished import');
|
||||||
|
const { stdout: diffOutput } = await exec('yarn cs diff');
|
||||||
|
expect(diffOutput).toContain('No differences between DB and sync directory');
|
||||||
|
});
|
||||||
|
|
||||||
test('Non-empty diff returns 1', async () => {
|
test('Non-empty diff returns 1', async () => {
|
||||||
await exec('rm -rf config/sync/admin-role.strapi-author.json');
|
await exec('rm -rf config/sync/admin-role.strapi-editor.json');
|
||||||
// Work around Jest not supporting custom error matching.
|
// Work around Jest not supporting custom error matching.
|
||||||
// https://github.com/facebook/jest/issues/8140
|
// https://github.com/facebook/jest/issues/8140
|
||||||
let error;
|
let error;
|
||||||
|
|
|
@ -3,6 +3,7 @@ module.exports = {
|
||||||
enabled: true,
|
enabled: true,
|
||||||
config: {
|
config: {
|
||||||
importOnBootstrap: false,
|
importOnBootstrap: false,
|
||||||
|
minify: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue