0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-17 23:44:39 -05:00

Fixed theme storage getting confused between tests

- When starting ghost for e2e tests we create a content folder in the os tmp dir
- This means that the folder can change between suites as ghost is started and restarted
- For the most part this is fine, but theme storage caches the path to config (which makes sense, it's not meant to change whilst Ghost is in-memory)
- This is a quick-n-dirty fix that just makes it possible to update that path in the tests, so we know it's in sync
- Ideally we'd not cache the path, use a function to fetch it etc, or fully reset the theme storage layer, but this is the fix I have working today
     and so it's going in to unblock things for now
This commit is contained in:
Hannah Wolfe 2022-02-11 10:34:43 +00:00
parent dabf143cae
commit 3e7039c47d
No known key found for this signature in database
GPG key ID: AB586C3B5AE5C037
3 changed files with 11 additions and 3 deletions

View file

@ -148,5 +148,8 @@ module.exports = {
let result = await getStorage().delete(themeName);
list.del(themeName);
return result;
},
updateStoragePath: function (storagePath) {
getStorage().storagePath = storagePath;
}
};

View file

@ -25,6 +25,8 @@ const redirectsUtils = require('./redirects');
const configUtils = require('./configUtils');
const mockManager = require('./e2e-framework-mock-manager');
const themeStorage = require('../../core/server/services/themes/storage');
const boot = require('../../core/boot');
const TestAgent = require('./test-agent');
const db = require('./db-utils');
@ -39,6 +41,7 @@ const startGhost = async () => {
// NOTE: need to pass this config to the server instance
configUtils.set('paths:contentPath', contentFolder);
themeStorage.updateStoragePath(configUtils.config.getContentPath('themes'));
const defaults = {
backend: true,

View file

@ -18,6 +18,7 @@ const urlService = require('../../core/server/services/url');
const settingsService = require('../../core/server/services/settings');
const routeSettingsService = require('../../core/server/services/route-settings');
const themeService = require('../../core/server/services/themes');
const themeStorage = require('../../core/server/services/themes/storage');
const limits = require('../../core/server/services/limits');
const customRedirectsService = require('../../core/server/services/redirects');
@ -69,6 +70,7 @@ const prepareContentFolder = (options) => {
* We use a tmp folder.
*/
configUtils.set('paths:contentPath', contentFolderForTests);
themeStorage.updateStoragePath(configUtils.config.getContentPath('themes'));
fs.ensureDirSync(contentFolderForTests);
fs.ensureDirSync(path.join(contentFolderForTests, 'data'));