diff --git a/core/server/services/url/index.js b/core/server/services/url/index.js index 00495ed8c0..1199597ac0 100644 --- a/core/server/services/url/index.js +++ b/core/server/services/url/index.js @@ -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 diff --git a/core/shared/config/env/config.testing-mysql.json b/core/shared/config/env/config.testing-mysql.json index f2fafeb9a8..c14947c315 100644 --- a/core/shared/config/env/config.testing-mysql.json +++ b/core/shared/config/env/config.testing-mysql.json @@ -50,5 +50,9 @@ "useTinfoil": true, "useStructuredData": true }, - "useMinFiles": false + "useMinFiles": false, + "paths": { + "fixtures": "test/utils/fixtures/fixtures", + "urlCache": "test/utils/fixtures/urls" + } } diff --git a/core/shared/config/env/config.testing.json b/core/shared/config/env/config.testing.json index 398a7cc9c7..18a35aafde 100644 --- a/core/shared/config/env/config.testing.json +++ b/core/shared/config/env/config.testing.json @@ -51,6 +51,7 @@ }, "useMinFiles": false, "paths": { - "fixtures": "test/utils/fixtures/fixtures" + "fixtures": "test/utils/fixtures/fixtures", + "urlCache": "test/utils/fixtures/urls" } } diff --git a/test/unit/shared/config/loader.test.js b/test/unit/shared/config/loader.test.js index 30b901ea7a..30f3670755 100644 --- a/test/unit/shared/config/loader.test.js +++ b/test/unit/shared/config/loader.test.js @@ -97,6 +97,7 @@ describe('Config Loader', function () { 'contentPath', 'fixtures', 'assetSrc', + 'urlCache', 'appRoot', 'corePath', 'clientAssets',