Skip to content

Commit

Permalink
Don't use pnpm-lock.yaml filename for test data because it confuses C…
Browse files Browse the repository at this point in the history
…VE scanners
  • Loading branch information
mbeckem committed Nov 6, 2024
1 parent 1e6a3cc commit cd5e3c3
Show file tree
Hide file tree
Showing 12 changed files with 28,112 additions and 22,019 deletions.
20 changes: 13 additions & 7 deletions integration-tests/check-pnpm-duplicates-tests/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
// SPDX-FileCopyrightText: 2023 Open Pioneer project (https://github.com/open-pioneer)
// SPDX-License-Identifier: Apache-2.0
import { cpSync, rmSync } from "node:fs";
import { resolve } from "node:path";
import { it } from "vitest";
import { TEST_DATA_DIR } from "./paths";
import { beforeAll, expect, it } from "vitest";
import { TEMP_DATA_DIR, TEST_DATA_DIR } from "./paths";
import { runCli } from "./runCli";
import { expect } from "vitest";

const LOCKFILE_DIR = resolve(TEST_DATA_DIR, "simple-dups-lockfile");
const LOCKFILE_DIR = resolve(TEMP_DATA_DIR, "project-dir");

beforeAll(() => {
const sourceLockfile = resolve(TEST_DATA_DIR, "_pnpm-lock.yaml");
rmSync(LOCKFILE_DIR, { recursive: true, force: true });
cpSync(sourceLockfile, resolve(LOCKFILE_DIR, "pnpm-lock.yaml"), { recursive: true });
});

it("reports all duplicates by default", async () => {
const result = await runCli(LOCKFILE_DIR, undefined);
Expand Down Expand Up @@ -103,7 +109,7 @@ it("reports all duplicates by default", async () => {
});

it("supports filtering dev dependencies", async () => {
const result = await runCli(LOCKFILE_DIR, resolve(LOCKFILE_DIR, "only-prod-dups.yaml"));
const result = await runCli(LOCKFILE_DIR, resolve(TEST_DATA_DIR, "only-prod-dups.yaml"));
expect(result).toMatchInlineSnapshot(`
{
"exitCode": 1,
Expand Down Expand Up @@ -133,7 +139,7 @@ it("supports filtering dev dependencies", async () => {
});

it("supports allowing duplicates", async () => {
const result = await runCli(LOCKFILE_DIR, resolve(LOCKFILE_DIR, "allow-dups.yaml"));
const result = await runCli(LOCKFILE_DIR, resolve(TEST_DATA_DIR, "allow-dups.yaml"));
expect(result).toMatchInlineSnapshot(`
{
"exitCode": 0,
Expand All @@ -144,7 +150,7 @@ it("supports allowing duplicates", async () => {
});

it("warns when rules are redundant", async () => {
const result = await runCli(LOCKFILE_DIR, resolve(LOCKFILE_DIR, "redundant-rules.yaml"));
const result = await runCli(LOCKFILE_DIR, resolve(TEST_DATA_DIR, "redundant-rules.yaml"));
expect(result).toMatchInlineSnapshot(`
{
"exitCode": 0,
Expand Down
1 change: 1 addition & 0 deletions integration-tests/check-pnpm-duplicates-tests/paths.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { resolve } from "node:path";
import { fileURLToPath } from "node:url";

export const PACKAGE_DIR = resolve(fileURLToPath(import.meta.url), "..");
export const TEMP_DATA_DIR = resolve(PACKAGE_DIR, "temp");
export const TEST_DATA_DIR = resolve(PACKAGE_DIR, "test-data");

const PACKAGE_JSON_FILE = resolve(PACKAGE_DIR, "package.json");
Expand Down
Loading

0 comments on commit cd5e3c3

Please sign in to comment.