Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`rdme openapi validate > CI tests > should fail if user attempts to pass \`--github\` flag in CI environment 1`] = `
[Error: Parsing --github
{
"error": [Error: Parsing --github
The \`--github\` flag is only for usage in non-CI environments.
See more help with --help]
See more help with --help],
"stderr": "",
"stdout": "",
}
`;

exports[`rdme openapi validate > CI tests > should successfully validate prompt and not run GHA onboarding 1`] = `
Expand Down
14 changes: 4 additions & 10 deletions __tests__/commands/openapi/validate.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from 'vite

import Command from '../../../src/commands/openapi/validate.js';
import { gitMock } from '../../helpers/git-mock.js';
import { type OclifOutput, runCommand, runCommandWithHooks } from '../../helpers/oclif.js';
import { type OclifOutput, runCommand } from '../../helpers/oclif.js';

describe('rdme openapi validate', () => {
let run: (args?: string[]) => OclifOutput;
Expand Down Expand Up @@ -96,15 +96,9 @@ describe('rdme openapi validate', () => {
});

it('should fail if user attempts to pass `--github` flag in CI environment', async () => {
return expect(
(
await runCommandWithHooks([
'openapi validate',
'__tests__/__fixtures__/petstore-simple-weird-version.json',
'--github',
])
).error,
).toMatchSnapshot();
const spec = '__tests__/__fixtures__/petstore-simple-weird-version.json';

await expect(run([spec, '--github'])).resolves.toMatchSnapshot();
});
});

Expand Down
12 changes: 1 addition & 11 deletions __tests__/helpers/oclif.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { CommandClass } from '../../src/index.js';
import path from 'node:path';

import { Config } from '@oclif/core';
import { captureOutput, runCommand as oclifRunCommand } from '@oclif/test';
import { captureOutput } from '@oclif/test';

export type OclifOutput<T = string> = ReturnType<typeof captureOutput<T>>;

Expand Down Expand Up @@ -63,13 +63,3 @@ export function runCommandAndReturnResult(Command: CommandClass) {
return result;
};
}

/**
* This runs the command you pass in against the args you pass in.
* This helper is not ideal in that `vitest --watch` won't reload,
* but it's helpful if you need to run assertions against the command's hooks.
*/
export async function runCommandWithHooks(args?: string[]) {
const oclifConfig = await setupOclifConfig();
return oclifRunCommand(args, oclifConfig, { testNodeEnv });
}
Loading
Loading