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

cadl-ranch-specs, add basic test case of clientInitialization #727

Closed
Show file tree
Hide file tree
Changes from 2 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
5 changes: 5 additions & 0 deletions .changeset/nasty-fishes-itch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@azure-tools/cadl-ranch-specs": patch
---

Add test case for client initialization
9 changes: 9 additions & 0 deletions packages/cadl-ranch-specs/cadl-ranch-summary.md
Original file line number Diff line number Diff line change
Expand Up @@ -1453,6 +1453,15 @@ Expected response body:
}
```

### Client_Initialization_Basic

- Endpoint: `post /client/initialization/basic/sub-client/{name}:action`

Testing that "SubClient" be initialized with "name" client property,
and that the "action" API under "SubClient" does not take "name" parameter in method signature.

Use "subclient1" as "name" parameter in test.

### Client_Naming_Header_request

- Endpoint: `post /client/naming/header`
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import "@typespec/http";
import "@azure-tools/cadl-ranch-expect";
import "@azure-tools/typespec-client-generator-core";

using TypeSpec.Http;
using Azure.ClientGenerator.Core;

/**
* Describe client with `@clientInitialization`
*/
@supportedBy("dpg")
@scenarioService("/client/initialization/basic")
@scenario
@scenarioDoc("""
Testing that "SubClient" be initialized with "name" client property,
and that the "action" API under "SubClient" does not take "name" parameter in method signature.

Use "subclient1" as "name" parameter in test.
""")
namespace Client.Initialization.Basic;

model SubClientOptions {
name: string;
}

@clientInitialization(SubClientOptions)
interface SubClient {
@post
@route("/sub-client/{name}:action")
action(@path name: string): void;
Comment on lines +29 to +30
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure, maybe add another parameter that will be taken in method signature, as a contrast?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I will first update to our local test first, as this one likely going to take time.
microsoft/typespec#5027

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { passOnSuccess, mockapi } from "@azure-tools/cadl-ranch-api";
import { ScenarioMockApi } from "@azure-tools/cadl-ranch-api";

export const Scenarios: Record<string, ScenarioMockApi> = {};

Scenarios.Client_Initialization_Basic = passOnSuccess(
mockapi.post("/client/initialization/basic/sub-client/subclient1:action", (req) => {
return {
status: 204,
};
}),
);
Loading