Skip to content

Commit

Permalink
test: update assertions
Browse files Browse the repository at this point in the history
  • Loading branch information
merceyz committed Apr 20, 2024
1 parent 6e62f29 commit a82e453
Showing 1 changed file with 23 additions and 23 deletions.
46 changes: 23 additions & 23 deletions tests/main.test.ts
Expand Up @@ -999,13 +999,13 @@ describe(`handle integrity checks`, () => {
await xfs.mktempPromise(async cwd => {
await expect(runCli(cwd, [`pnpm@1.x`, `--version`], true)).resolves.toMatchObject({
exitCode: 1,
stdout: /Signature does not match/,
stderr: ``,
stderr: /Signature does not match/,
stdout: ``,
});
await expect(runCli(cwd, [`yarn@stable`, `--version`], true)).resolves.toMatchObject({
exitCode: 1,
stdout: /Signature does not match/,
stderr: ``,
stderr: /Signature does not match/,
stdout: ``,
});
});
});
Expand All @@ -1015,19 +1015,19 @@ describe(`handle integrity checks`, () => {
await xfs.mktempPromise(async cwd => {
await expect(runCli(cwd, [`pnpm`, `--version`], true)).resolves.toMatchObject({
exitCode: 1,
stdout: /Mismatch hashes. Expected [a-f0-9]{128}, got [a-f0-9]{128}/,
stderr: ``,
stderr: /Mismatch hashes. Expected [a-f0-9]{128}, got [a-f0-9]{128}/,
stdout: ``,
});
// A second time to validate the invalid version was not cached.
await expect(runCli(cwd, [`pnpm`, `--version`], true)).resolves.toMatchObject({
exitCode: 1,
stdout: /Mismatch hashes. Expected [a-f0-9]{128}, got [a-f0-9]{128}/,
stderr: ``,
stderr: /Mismatch hashes. Expected [a-f0-9]{128}, got [a-f0-9]{128}/,
stdout: ``,
});
await expect(runCli(cwd, [`yarn`, `--version`], true)).resolves.toMatchObject({
exitCode: 1,
stdout: /Mismatch hashes. Expected [a-f0-9]{128}, got [a-f0-9]{128}/,
stderr: ``,
stderr: /Mismatch hashes. Expected [a-f0-9]{128}, got [a-f0-9]{128}/,
stdout: ``,
});
await expect(runCli(cwd, [`use`, `pnpm`], true)).resolves.toMatchObject({
exitCode: 1,
Expand All @@ -1042,19 +1042,19 @@ describe(`handle integrity checks`, () => {
await xfs.mktempPromise(async cwd => {
await expect(runCli(cwd, [`pnpm`, `--version`], true)).resolves.toMatchObject({
exitCode: 1,
stdout: /Signature does not match/,
stderr: ``,
stderr: /Signature does not match/,
stdout: ``,
});
// A second time to validate the invalid version was not cached.
await expect(runCli(cwd, [`pnpm`, `--version`], true)).resolves.toMatchObject({
exitCode: 1,
stdout: /Signature does not match/,
stderr: ``,
stderr: /Signature does not match/,
stdout: ``,
});
await expect(runCli(cwd, [`yarn`, `--version`], true)).resolves.toMatchObject({
exitCode: 1,
stdout: /Signature does not match/,
stderr: ``,
stderr: /Signature does not match/,
stdout: ``,
});
await expect(runCli(cwd, [`use`, `pnpm`], true)).resolves.toMatchObject({
exitCode: 1,
Expand All @@ -1069,8 +1069,8 @@ describe(`handle integrity checks`, () => {
await xfs.mktempPromise(async cwd => {
await expect(runCli(cwd, [`yarn@1.9998.9999`, `--version`], true)).resolves.toMatchObject({
exitCode: 1,
stdout: /Signature does not match/,
stderr: ``,
stderr: /Signature does not match/,
stdout: ``,
});
await expect(runCli(cwd, [`use`, `yarn@1.9998.9999`], true)).resolves.toMatchObject({
exitCode: 1,
Expand All @@ -1085,8 +1085,8 @@ describe(`handle integrity checks`, () => {
await xfs.mktempPromise(async cwd => {
await expect(runCli(cwd, [`yarn@1.9998.9999`, `--version`], true)).resolves.toMatchObject({
exitCode: 1,
stdout: /Mismatch hashes. Expected [a-f0-9]{128}, got [a-f0-9]{128}/,
stderr: ``,
stderr: /Mismatch hashes. Expected [a-f0-9]{128}, got [a-f0-9]{128}/,
stdout: ``,
});
await expect(runCli(cwd, [`use`, `yarn@1.9998.9999`], true)).resolves.toMatchObject({
exitCode: 1,
Expand All @@ -1102,10 +1102,10 @@ describe(`handle integrity checks`, () => {
const result = await runCli(cwd, [`yarn@1.9998.9999+sha1.deadbeef`, `--version`], true);
expect(result).toMatchObject({
exitCode: 1,
stderr: ``,
stdout: ``,
});
const match = /Mismatch hashes. Expected deadbeef, got ([a-f0-9]{40})/.exec(result.stdout);
if (match == null) throw new Error(`Invalid output`, {cause: result.stdout});
const match = /Mismatch hashes. Expected deadbeef, got ([a-f0-9]{40})/.exec(result.stderr);
if (match == null) throw new Error(`Invalid output`, {cause: result.stderr});
await expect(runCli(cwd, [`yarn@1.9998.9999+sha1.${match[1]}`, `--version`], true)).resolves.toMatchObject({
exitCode: 0,
stdout: `yarn: Hello from custom registry\n`,
Expand Down

0 comments on commit a82e453

Please sign in to comment.