Skip to content

Commit

Permalink
[Tcgc] Fix etag (#365)
Browse files Browse the repository at this point in the history
  • Loading branch information
iscai-msft authored Mar 7, 2024
1 parent a156385 commit 6ce4713
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .chronus/changes/fix_etag-2024-2-5-12-2-26.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
changeKind: internal
packages:
- "@azure-tools/typespec-client-generator-core"
---

add azure etag test
35 changes: 35 additions & 0 deletions packages/typespec-client-generator-core/test/types.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,41 @@ describe("typespec-client-generator-core: types", () => {
}
});

it("etag from core", async () => {
const runnerWithCore = await createSdkTestRunner({
librariesToAdd: [AzureCoreTestLibrary],
autoUsings: ["Azure.Core"],
"filter-out-core-models": false,
emitterName: "@azure-tools/typespec-java",
});
await runnerWithCore.compile(`
@useDependency(Azure.Core.Versions.v1_0_Preview_2)
@service
namespace MyService {
@resource("users")
@doc("Details about a user.")
model User {
@key
@doc("The user's name.")
@visibility("read")
name: string;
...Azure.Core.EtagProperty;
}
@doc("Gets status.")
op getStatus is GetResourceOperationStatus<User>;
}
`);
const models = getAllModels(runnerWithCore.context);
const userModel = models.find(
(x) => x.kind === "model" && x.name === "User"
)! as SdkModelType;
strictEqual(userModel.properties.length, 2);
const etagProperty = userModel.properties.find((x) => x.nameInClient === "etag")!;
strictEqual(etagProperty.type.kind, "eTag");
});

it("unknown format", async function () {
await runner.compileWithBuiltInService(
`
Expand Down

0 comments on commit 6ce4713

Please sign in to comment.