blob: d95d56f88c6cc8741ef49ee3c442072b797c6cc6 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
import { it } from 'node:test';
import * as dotenv from 'dotenv';
import { tmpdir } from 'node:os';
import * as assert from 'node:assert';
import { readSecret } from '#util/secretUtils.js';
import { writeFile, mkdtemp } from 'node:fs/promises';
dotenv.config();
await it('Should fail on nonexistant secret', async () => {
const secretPath = (await mkdtemp(tmpdir())) + '/secret';
await assert.rejects(readSecret('Nonexistant secret', secretPath));
});
await it('Should read secret from file', async () => {
const secretPath = (await mkdtemp(tmpdir())) + '/secret';
await writeFile(secretPath, 'testsecret');
await assert.doesNotReject(readSecret('Test secret', secretPath));
await assert.equal(
await readSecret('Test secret', secretPath),
'testsecret'
);
});
|