UNPKG

kubricate

Version:

A TypeScript framework for building reusable, type-safe Kubernetes infrastructure — without the YAML mess.

35 lines (34 loc) 1.45 kB
"use strict"; var _vitest = /*#__PURE__*/require("vitest"); var _InMemoryConnector = /*#__PURE__*/require("./InMemoryConnector.js"); (0, _vitest.describe)('InMemoryConnector', () => { (0, _vitest.it)('loads a known secret and retrieves it', async () => { const connector = new _InMemoryConnector.InMemoryConnector({ SECRET_KEY: 'value123' }); await connector.load(['SECRET_KEY']); (0, _vitest.expect)(connector.get('SECRET_KEY')).toBe('value123'); }); (0, _vitest.it)('throws if trying to get a secret before loading it', () => { const connector = new _InMemoryConnector.InMemoryConnector({ SECRET_KEY: 'value123' }); (0, _vitest.expect)(() => connector.get('SECRET_KEY')).toThrow('Secret SECRET_KEY not loaded'); }); (0, _vitest.it)('throws if the secret does not exist in config', async () => { const connector = new _InMemoryConnector.InMemoryConnector({ SECRET_KEY: 'value123' }); await (0, _vitest.expect)(connector.load(['MISSING_KEY'])).rejects.toThrow('Missing secret: MISSING_KEY'); }); (0, _vitest.it)('supports loading multiple keys at once', async () => { const connector = new _InMemoryConnector.InMemoryConnector({ A: '1', B: '2' }); await connector.load(['A', 'B']); (0, _vitest.expect)(connector.get('A')).toBe('1'); (0, _vitest.expect)(connector.get('B')).toBe('2'); }); }); //# sourceMappingURL=InMemoryConnector.test.js.map