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 dfddf92
Showing 1 changed file with 29 additions and 29 deletions.
58 changes: 29 additions & 29 deletions tests/main.test.ts
Expand Up @@ -999,8 +999,8 @@ 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,
Expand All @@ -1015,24 +1015,24 @@ 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,
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: ``,
});
});
});
Expand All @@ -1042,24 +1042,24 @@ 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,
stdout: /Signature does not match/,
stderr: ``,
stderr: /Signature does not match/,
stdout: ``,
});
});
});
Expand All @@ -1069,13 +1069,13 @@ 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,
stdout: /Signature does not match/,
stderr: ``,
stderr: /Signature does not match/,
stdout: ``,
});
});
});
Expand All @@ -1085,13 +1085,13 @@ 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,
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: ``,
});
});
});
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 dfddf92

Please sign in to comment.