Skip to content

Commit

Permalink
fix(cli): Add in-lined test case to no-duplicate-overrides.test.ts (
Browse files Browse the repository at this point in the history
#5561)

* fix(cli): Add `in-lined` test case to `no-duplicate-overrides.test.ts`

* us
  • Loading branch information
eyw520 authored Jan 8, 2025
1 parent aaf3262 commit 41882ee
Show file tree
Hide file tree
Showing 5 changed files with 104 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`no-duplicate-overrides > complex failure > ./__snapshots__/openapi/complex.json 1`] = `
exports[`no-duplicate-overrides > complex failure 1`] = `
[
{
"message": "SDK method a.b.c.d already exists (x-fern-sdk-group-name: a.b.c, x-fern-sdk-method-name: d)",
Expand All @@ -15,7 +15,22 @@ exports[`no-duplicate-overrides > complex failure > ./__snapshots__/openapi/comp
]
`;

exports[`no-duplicate-overrides > simple failure > ./__snapshots__/openapi/simple.json 1`] = `
exports[`no-duplicate-overrides > inlined failure 1`] = `
[
{
"message": "SDK method a.b already exists (x-fern-sdk-group-name: a, x-fern-sdk-method-name: b)",
"nodePath": [
"paths",
"/a/b",
"get",
],
"relativeFilepath": "openapi/openapi.yml",
"severity": "error",
},
]
`;

exports[`no-duplicate-overrides > simple failure 1`] = `
[
{
"message": "SDK method a.b already exists (x-fern-sdk-group-name: a, x-fern-sdk-method-name: b)",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"organization": "twelvelabs",
"version": "0.44.11"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
api:
specs:
- openapi: ./openapi/openapi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
openapi: 3.1.0
info:
title: Sample API
version: 1.0.0
paths:
/a/{alpha}:
post:
x-fern-sdk-group-name:
- a
x-fern-sdk-method-name: b
summary: Test summary
description: Test description
parameters:
- name: alpha
in: path
required: true
schema:
type: string
operationId: operation-id-a
requestBody:
description: Request body containing beta
required: true
content:
application/json:
schema:
type: string
responses:
'201':
description: Resource created successfully
content:
application/json:
schema:
type: string

/a/b:
get:
x-fern-sdk-group-name:
- a
x-fern-sdk-method-name: b
summary: Test summary
description: Test description
parameters:
- name: alpha
in: query
required: true
schema:
type: string
operationId: operation-id-b
responses:
'200':
description: Successful retrieval
content:
application/json:
schema:
type: string
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ describe("no-duplicate-overrides", () => {
}
];

expect(violations).toMatchSnapshot("./__snapshots__/openapi/simple.json");
expect(violations).toMatchSnapshot();
}, 10_000);

it("complex failure", async () => {
Expand All @@ -48,6 +48,29 @@ describe("no-duplicate-overrides", () => {
}
];

expect(violations).toMatchSnapshot("./__snapshots__/openapi/complex.json");
expect(violations).toMatchSnapshot();
}, 10_000);

it("inlined failure", async () => {
const violations = await getViolationsForRule({
rule: NoDuplicateOverridesRule,
absolutePathToWorkspace: join(
AbsoluteFilePath.of(__dirname),
RelativeFilePath.of("fixtures"),
RelativeFilePath.of("in-lined")
),
cliVersion: "0.1.3-rc0"
});

const expectedViolations: ValidationViolation[] = [
{
severity: "error",
relativeFilepath: RelativeFilePath.of("openapi/openapi.yml"),
nodePath: ["paths", "/a/b", "get"],
message: "SDK method a.b.c.d already exists (x-fern-sdk-group-name: a.b.c, x-fern-sdk-method-name: d)"
}
];

expect(violations).toMatchSnapshot();
}, 10_000);
});

0 comments on commit 41882ee

Please sign in to comment.