31 lines
1.0 KiB
JavaScript
31 lines
1.0 KiB
JavaScript
|
|
'use strict';
|
||
|
|
|
||
|
|
const test = require('node:test');
|
||
|
|
const assert = require('node:assert/strict');
|
||
|
|
|
||
|
|
const HttpBackend = require('../../src/registry/backends/HttpBackend');
|
||
|
|
|
||
|
|
test('HttpBackend disabled by default — loadAll throws explanatory error', () => {
|
||
|
|
delete process.env.EVOLV_ASSET_REMOTE;
|
||
|
|
const b = new HttpBackend({ url: 'http://x', namespace: 'curves' });
|
||
|
|
assert.throws(() => b.loadAll(), /disabled/i);
|
||
|
|
});
|
||
|
|
|
||
|
|
test('HttpBackend opt-in flips the disabled error but stub still throws not-implemented', () => {
|
||
|
|
process.env.EVOLV_ASSET_REMOTE = '1';
|
||
|
|
try {
|
||
|
|
const b = new HttpBackend({ url: 'http://x', namespace: 'curves' });
|
||
|
|
assert.throws(() => b.loadAll(), /not yet implemented/i);
|
||
|
|
} finally {
|
||
|
|
delete process.env.EVOLV_ASSET_REMOTE;
|
||
|
|
}
|
||
|
|
});
|
||
|
|
|
||
|
|
test('HttpBackend.enabled reflects env var', () => {
|
||
|
|
delete process.env.EVOLV_ASSET_REMOTE;
|
||
|
|
assert.equal(HttpBackend.enabled, false);
|
||
|
|
process.env.EVOLV_ASSET_REMOTE = '1';
|
||
|
|
assert.equal(HttpBackend.enabled, true);
|
||
|
|
delete process.env.EVOLV_ASSET_REMOTE;
|
||
|
|
});
|