Skip to content

Commit a84457f

Browse files
pshao25Pan Shao
and
Pan Shao
authored
Add test for duration-constant (#2379)
Add tests for duration-constant as the first step to fix #1901 --------- Co-authored-by: Pan Shao <[email protected]>
1 parent 24122e9 commit a84457f

File tree

4 files changed

+72
-0
lines changed

4 files changed

+72
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
changeKind: feature
3+
packages:
4+
- "@azure-tools/azure-http-specs"
5+
---
6+
7+
Add test for duration-constant format

packages/azure-http-specs/spec-summary.md

+13
Original file line numberDiff line numberDiff line change
@@ -722,6 +722,19 @@ Expected response body:
722722
}
723723
```
724724

725+
### Azure_Encode_Duration_durationConstant
726+
727+
- Endpoint: `put /azure/encode/duration/duration-constant`
728+
729+
Test case for azure specific encoding. SDK should generate correct serialization format according to the set encoding.
730+
Expected request body:
731+
732+
```json
733+
{
734+
"input": "1.02:59:59.5000000"
735+
}
736+
```
737+
725738
### Azure_Example_Basic
726739

727740
- Endpoint: `post /azure/example/basic/basic`
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import "@typespec/http";
2+
import "@typespec/spector";
3+
import "@azure-tools/typespec-client-generator-core";
4+
5+
using TypeSpec.Http;
6+
using global.Azure.ClientGenerator.Core;
7+
using Spector;
8+
9+
@doc("Test for azure related encode decorator.")
10+
@scenarioService("/azure/encode/duration")
11+
namespace _Specs_.Azure.Encode.Duration;
12+
13+
@@clientNamespace(_Specs_.Azure.Encode.Duration, "azure.encode.duration", "java");
14+
15+
model DurationModel {
16+
@encode("duration-constant")
17+
input: duration;
18+
}
19+
20+
@scenario
21+
@scenarioDoc("""
22+
Test case for azure specific encoding. SDK should generate correct serialization format according to the set encoding.
23+
Expected request body:
24+
```json
25+
{
26+
"input": "1.02:59:59.5000000"
27+
}
28+
```
29+
""")
30+
@doc("Test duration with azure specific encoding.")
31+
@put
32+
@route("/duration-constant")
33+
op durationConstant(@body body: DurationModel): NoContentResponse;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { passOnSuccess, ScenarioMockApi } from "@typespec/spec-api";
2+
3+
export const Scenarios: Record<string, ScenarioMockApi> = {};
4+
5+
Scenarios.Azure_Encode_Duration_durationConstant = passOnSuccess([
6+
{
7+
uri: "/azure/encode/duration/duration-constant",
8+
method: "put",
9+
request: {
10+
body: {
11+
input: "1.02:59:59.5000000",
12+
},
13+
},
14+
response: {
15+
status: 204,
16+
},
17+
kind: "MockApiDefinition",
18+
},
19+
]);

0 commit comments

Comments
 (0)