Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[suppressions] Add end-to-end tests #29858

Merged
merged 6 commits into from
Jul 17, 2024
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
Empty file.
Empty file.
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- tool: TestTool
path: foo.json
reason: test
48 changes: 48 additions & 0 deletions eng/tools/suppressions/test/suppressions.e2e.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import { expect, test } from "vitest";
import { Suppression, getSuppressions } from "../src/suppressions.js";
import { join } from "path";

async function getTestSuppressions(
path: string,
tool: string = "TestTool",
): Promise<Suppression[]> {
return await getSuppressions(tool, join(__dirname, "e2e", path));
}

test.concurrent("no suppressions.yaml", async () => {
const suppressions: Suppression[] = await getTestSuppressions("noSuppressionsYaml");
expect(suppressions).toEqual([]);
});

test.concurrent("empty suppressions.yaml", async () => {
const suppressions: Suppression[] = await getTestSuppressions("emptySuppressionsYaml");
expect(suppressions).toEqual([]);
});

test.concurrent("suppress foo.json, get foo.json", async () => {
const suppressions: Suppression[] = await getTestSuppressions(
join("suppressFooJson", "foo.json"),
);
expect(suppressions).toEqual([
{
tool: "TestTool",
paths: ["foo.json"],
reason: "test",
},
]);
});

test.concurrent("suppress foo.json, get bar.json", async () => {
const suppressions: Suppression[] = await getTestSuppressions(
join("suppressFooJson", "bar.json"),
);
expect(suppressions).toEqual([]);
});

test.concurrent("suppress foo.json, get foo.json w/ different tool", async () => {
const suppressions: Suppression[] = await getTestSuppressions(
join("suppressFooJson", "foo.json"),
"TestTool2",
);
expect(suppressions).toEqual([]);
});