Skip to content

Commit

Permalink
Add test scenario.
Browse files Browse the repository at this point in the history
  • Loading branch information
tjprescott committed Nov 10, 2023
1 parent 2e8b605 commit 1ff9054
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions packages/versioning/test/incompatible-versioning.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,40 @@ describe("versioning: validate incompatible references", () => {
});
});

describe("operation", () => {
it("emit diagnostic when unversioned op has a versioned model as a parameter", async () => {
const diagnostics = await runner.diagnose(`
@added(Versions.v2)
model Foo {}
op test(param: Foo): void;
`);
expectDiagnostics(diagnostics, {
code: "@typespec/versioning/incompatible-versioned-reference",
message:
"'TestService.test' is referencing versioned type 'TestService.Foo' but is not versioned itself.",
});
});

it("emit diagnostic when unversioned op based on a template has a versioned model as a parameter", async () => {
const diagnostics = await runner.diagnose(`
@added(Versions.v2)
model Foo {}
model Template<T> {
op test(param: T): void;
}
op test is Template<Foo>;
`);
expectDiagnostics(diagnostics, {
code: "@typespec/versioning/incompatible-versioned-reference",
message:
"'TestService.test' is referencing versioned type 'TestService.Foo' but is not versioned itself.",
});
});
});

describe("operation return type", () => {
it("emit diagnostic when unversioned op is returning versioned model", async () => {
const diagnostics = await runner.diagnose(`
Expand Down

0 comments on commit 1ff9054

Please sign in to comment.