0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-06 22:40:14 -05:00

Introduced booting from fixture url cache in test environment

refs https://github.com/TryGhost/Toolbox/issues/135

- To be able to reliably start ghost instance without a frontend the process needs access to urls/resources caches
- Storing the configuration in "paths" for now as there's no better place for it untill we are able to mock the content folder in pre-boot
This commit is contained in:
Naz 2021-11-17 20:05:17 +04:00 committed by naz
parent c12ae81ece
commit 3b390639c4
4 changed files with 19 additions and 4 deletions

View file

@ -5,8 +5,17 @@ const UrlService = require('./UrlService');
// NOTE: instead of a path we could give UrlService a "data-resolver" of some sort
// so it doesn't have to contain the logic to read data at all. This would be
// a possible improvement in the future
const urlsCachePath = path.join(config.getContentPath('data'), 'urls.json');
const resourcesCachePath = path.join(config.getContentPath('data'), 'resources.json');
let urlsCachePath = path.join(config.getContentPath('data'), 'urls.json');
let resourcesCachePath = path.join(config.getContentPath('data'), 'resources.json');
// TODO: remove this hack in favor of loading from the content path when it's possible to do so
// by mocking content folders in pre-boot phase
if (process.env.NODE_ENV.match(/^testing/)){
urlsCachePath = path.join(config.get('paths').urlCache, 'urls.json');
resourcesCachePath = path.join(config.get('paths').urlCache, 'resources.json');
}
const urlService = new UrlService({urlsCachePath, resourcesCachePath});
// Singleton

View file

@ -50,5 +50,9 @@
"useTinfoil": true,
"useStructuredData": true
},
"useMinFiles": false
"useMinFiles": false,
"paths": {
"fixtures": "test/utils/fixtures/fixtures",
"urlCache": "test/utils/fixtures/urls"
}
}

View file

@ -51,6 +51,7 @@
},
"useMinFiles": false,
"paths": {
"fixtures": "test/utils/fixtures/fixtures"
"fixtures": "test/utils/fixtures/fixtures",
"urlCache": "test/utils/fixtures/urls"
}
}

View file

@ -97,6 +97,7 @@ describe('Config Loader', function () {
'contentPath',
'fixtures',
'assetSrc',
'urlCache',
'appRoot',
'corePath',
'clientAssets',