test: create token assertion
This commit is contained in:
@@ -1,5 +1,10 @@
|
|||||||
import { testSuite, expect } from 'manten';
|
import { testSuite, expect } from 'manten';
|
||||||
import { createFixture, createGit, files } from '../../utils.js';
|
import {
|
||||||
|
assertOpenAiToken,
|
||||||
|
createFixture,
|
||||||
|
createGit,
|
||||||
|
files,
|
||||||
|
} from '../../utils.js';
|
||||||
|
|
||||||
export default testSuite(({ describe }) => {
|
export default testSuite(({ describe }) => {
|
||||||
if (process.platform === 'win32') {
|
if (process.platform === 'win32') {
|
||||||
@@ -8,10 +13,7 @@ export default testSuite(({ describe }) => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!process.env.OPENAI_KEY) {
|
assertOpenAiToken();
|
||||||
console.warn('⚠️ process.env.OPENAI_KEY is necessary to run these tests. Skipping...');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
describe('CLI', async ({ test, describe }) => {
|
describe('CLI', async ({ test, describe }) => {
|
||||||
test('Excludes files', async () => {
|
test('Excludes files', async () => {
|
||||||
|
|||||||
@@ -1,8 +1,15 @@
|
|||||||
import { testSuite, expect } from 'manten';
|
import { testSuite, expect } from 'manten';
|
||||||
import { createFixture, createGit, files } from '../utils.js';
|
import {
|
||||||
|
assertOpenAiToken,
|
||||||
|
createFixture,
|
||||||
|
createGit,
|
||||||
|
files,
|
||||||
|
} from '../utils.js';
|
||||||
|
|
||||||
export default testSuite(({ describe }) => {
|
export default testSuite(({ describe }) => {
|
||||||
describe('Git hook', ({ test }) => {
|
describe('Git hook', ({ test }) => {
|
||||||
|
assertOpenAiToken();
|
||||||
|
|
||||||
test('errors when not in Git repo', async () => {
|
test('errors when not in Git repo', async () => {
|
||||||
const { fixture, aicommits } = await createFixture(files);
|
const { fixture, aicommits } = await createFixture(files);
|
||||||
const { exitCode, stderr } = await aicommits(['hook', 'install'], {
|
const { exitCode, stderr } = await aicommits(['hook', 'install'], {
|
||||||
|
|||||||
@@ -77,3 +77,9 @@ export const files = Object.freeze({
|
|||||||
'.aicommits': `OPENAI_KEY=${process.env.OPENAI_KEY}`,
|
'.aicommits': `OPENAI_KEY=${process.env.OPENAI_KEY}`,
|
||||||
'data.json': 'Lorem ipsum dolor sit amet '.repeat(10),
|
'data.json': 'Lorem ipsum dolor sit amet '.repeat(10),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export const assertOpenAiToken = () => {
|
||||||
|
if (!process.env.OPENAI_KEY) {
|
||||||
|
throw new Error('⚠️ process.env.OPENAI_KEY is necessary to run these tests. Skipping...');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user