feat: request timeout config (#191)

Co-authored-by: Hiroki Osame <hiroki.osame@gmail.com>
This commit is contained in:
Rocktim
2023-04-08 17:54:47 +05:30
committed by GitHub
parent 75eee29a4e
commit 42a2a39f6f
7 changed files with 79 additions and 7 deletions

View File

@@ -4,7 +4,7 @@ import { testSuite, expect } from 'manten';
import { createFixture } from '../utils.js';
export default testSuite(({ describe }) => {
describe('config', async ({ test }) => {
describe('config', async ({ test, describe }) => {
const { fixture, aicommits } = await createFixture();
const configPath = path.join(fixture.path, '.aicommits');
const openAiToken = 'OPENAI_KEY=sk-abc';
@@ -49,6 +49,25 @@ export default testSuite(({ describe }) => {
expect(stderr).toBe('');
});
await describe('timeout', ({ test }) => {
test('setting invalid timeout config', async () => {
const { stderr } = await aicommits(['config', 'set', 'timeout=abc'], {
reject: false,
});
expect(stderr).toMatch('Must be an integer');
});
test('setting valid timeout config', async () => {
const timeout = 'timeout=20000';
await aicommits(['config', 'set', timeout]);
const configFile = await fs.readFile(configPath, 'utf8');
expect(configFile).toMatch(timeout);
});
});
await fixture.rm();
});
});