Skip to content

Commit

Permalink
Add test for specific desired lro results
Browse files Browse the repository at this point in the history
  • Loading branch information
markcowl committed Jul 16, 2024
1 parent e44d99e commit ea48404
Showing 1 changed file with 65 additions and 0 deletions.
65 changes: 65 additions & 0 deletions packages/typespec-azure-resource-manager/test/lro-metadata.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,71 @@ describe("typespec-azure-resource-manager: ARM LRO Tests", () => {
deepStrictEqual(metadata.finalResultPath, undefined);
deepStrictEqual(metadata.finalStateVia, "location");
});
it("Returns correct metadata for Async action with void return type", async () => {
const [metadata, _diag, _runner] = await getLroMetadataFor(
`
@armProviderNamespace
@useDependency(Azure.ResourceManager.Versions.v1_0_Preview_1)
namespace Microsoft.Test;
interface Operations extends Azure.ResourceManager.Operations {}
@doc("The state of the resource")
enum ResourceState {
Succeeded,
Canceled,
Failed
}
@doc("The widget properties")
model WidgetProperties {
@doc("I am a simple Resource Identifier")
simpleArmId: ResourceIdentifier;
@doc("The provisioning State")
provisioningState: ResourceState;
}
@doc("The result of the post request")
model ResultModel {
@doc("The result message")
message: string;
}
@doc("The request of the post request")
model RequestModel {
@doc("The request message")
message: string;
}
@doc("Foo resource")
model Widget is TrackedResource<WidgetProperties> {
@doc("Widget name")
@key("widgetName")
@segment("widgets")
@path
name: string;
}
@armResourceOperations(Widget)
interface Widgets {
get is ArmResourceRead<Widget>;
createOrUpdate is ArmResourceCreateOrReplaceAsync<Widget>;
update is ArmResourcePatchSync<Widget, WidgetProperties>;
delete is ArmResourceDeleteSync<Widget>;
doStuff is ArmResourceActionAsync<Widget, RequestModel, void, LroHeaders=ArmAsyncOperationHeader<FinalResult = void>>;
listByResourceGroup is ArmResourceListByParent<Widget>;
listBySubscription is ArmListBySubscription<Widget>;
}
`,
"doStuff"
);
ok(metadata);
deepStrictEqual(metadata.finalResult, "void");
deepStrictEqual(metadata.finalEnvelopeResult, "void");
deepStrictEqual(metadata.finalResultPath, undefined);
deepStrictEqual(metadata.finalStateVia, "azure-async-operation");
});

it("Returns correct metadata for Async CreateOrUpdate with union type ProvisioningState", async () => {
const [metadata, _diag, _runner] = await getLroMetadataFor(
Expand Down

0 comments on commit ea48404

Please sign in to comment.