Skip to content

Commit

Permalink
Revert "Add Test in Versioning/Removed" (#737)
Browse files Browse the repository at this point in the history
* Revert "Add Test in Versioning/Removed (#627)"

This reverts commit 92f3c4d.

* update

---------

Co-authored-by: Pan Shao <[email protected]>
  • Loading branch information
pshao25 and Pan Shao authored Sep 30, 2024
1 parent 4b31d3a commit 73a096b
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 145 deletions.
5 changes: 5 additions & 0 deletions .changeset/four-kings-think.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@azure-tools/cadl-ranch-specs": patch
---

Revert the change for version remove
43 changes: 0 additions & 43 deletions packages/cadl-ranch-specs/cadl-ranch-summary.md
Original file line number Diff line number Diff line change
Expand Up @@ -9109,49 +9109,6 @@ Expected request body:
{ "prop": "foo" }
```

### Versioning_Removed_modelV3

- Endpoint: `post /versioning/removed/api-version:{version}/v3`

path: "/versioning/removed/api-version:v1/v3"
Expected request body:

```json
{ "id": "123", "enumProp": "enumMemberV1" }
```

Expected response body:

```json
{ "id": "123", "enumProp": "enumMemberV1" }
```

path: "/versioning/removed/api-version:v2/v3"
Expected request body:

```json
{ "id": "123", "enumProp": "enumMemberV1" }
```

Expected response body:

```json
{ "id": "123", "enumProp": "enumMemberV1" }
```

path: "/versioning/removed/api-version:v2preview/v3"
Expected request body:

```json
{ "id": "123", "enumProp": "enumMemberV2Preview" }
```

Expected response body:

```json
{ "id": "123", "enumProp": "enumMemberV2Preview" }
```

### Versioning_Removed_v2

- Endpoint: `post /versioning/removed/api-version:{version}/v2`
Expand Down
71 changes: 3 additions & 68 deletions packages/cadl-ranch-specs/http/versioning/removed/main.tsp
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import "@typespec/http";
import "@azure-tools/cadl-ranch-expect";
import "@typespec/versioning";
import "@azure-tools/typespec-azure-core";

using TypeSpec.Http;
using TypeSpec.Versioning;
using TypeSpec.Rest;

/**
* Test for the `@removed` decorator.
Expand All @@ -22,7 +20,7 @@ using TypeSpec.Rest;
endpoint: url,

/**
* Need to be set as 'v1', 'v2preview' or 'v2' in client.
* Need to be set as 'v1' or 'v2' in client.
*/
version: Versions,
}
Expand All @@ -34,17 +32,12 @@ namespace Versioning.Removed;
*/
enum Versions {
/**
* The original version v1.
* The version v1.
*/
v1: "v1",

/**
* The V2 Preview version.
*/
v2preview: "v2preview",

/**
* The latest version v2.
* The version v2.
*/
v2: "v2",
}
Expand Down Expand Up @@ -73,29 +66,13 @@ model ModelV2 {
unionProp: UnionV2;
}

model ModelV3 {
id: string;

@removed(Versions.v2preview)
@added(Versions.v2)
enumProp: EnumV3;
}

enum EnumV2 {
@removed(Versions.v2)
enumMemberV1,

enumMemberV2,
}

enum EnumV3 {
@removed(Versions.v2preview)
@added(Versions.v2)
enumMemberV1,

enumMemberV2Preview,
}

@removed(Versions.v2)
union UnionV1 {
string,
Expand Down Expand Up @@ -146,45 +123,3 @@ interface InterfaceV1 {
@route("/v1")
v1InInterface(@body body: ModelV1): ModelV1;
}

/** This operation should be generated with the signatures of both the latest and the original versions, rather than preview version */
@scenario
@scenarioDoc("""
path: "/versioning/removed/api-version:v1/v3"
Expected request body:
```json
{ "id": "123", "enumProp": "enumMemberV1" }
```
Expected response body:
```json
{ "id": "123", "enumProp": "enumMemberV1" }
```
path: "/versioning/removed/api-version:v2/v3"
Expected request body:
```json
{ "id": "123", "enumProp": "enumMemberV1" }
```
Expected response body:
```json
{ "id": "123", "enumProp": "enumMemberV1" }
```
path: "/versioning/removed/api-version:v2preview/v3"
Expected request body:
```json
{ "id": "123", "enumProp": "enumMemberV2Preview" }
```
Expected response body:
```json
{ "id": "123", "enumProp": "enumMemberV2Preview" }
```
""")
@post
@route("/v3")
op modelV3(@body body: ModelV3): ModelV3;
35 changes: 1 addition & 34 deletions packages/cadl-ranch-specs/http/versioning/removed/mockapi.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,8 @@
import { mockapi, passOnSuccess, json } from "@azure-tools/cadl-ranch-api";
import { passOnSuccess, mockapi, json } from "@azure-tools/cadl-ranch-api";
import { ScenarioMockApi } from "@azure-tools/cadl-ranch-api";

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

const pathsAndProperties = [
{
path: "/versioning/removed/api-version:v1/v3",
expectedBody: { id: "123", enumProp: "enumMemberV1" },
responseBody: { id: "123", enumProp: "enumMemberV1" },
status: 200,
},
{
path: "/versioning/removed/api-version:v2/v3",
expectedBody: { id: "123", enumProp: "enumMemberV1" },
responseBody: { id: "123", enumProp: "enumMemberV1" },
status: 200,
},
{
path: "/versioning/removed/api-version:v2preview/v3",
expectedBody: { id: "123", enumProp: "enumMemberV2Preview" },
responseBody: { id: "123", enumProp: "enumMemberV2Preview" },
status: 200,
},
];

Scenarios.Versioning_Removed_v2 = passOnSuccess(
mockapi.post("/versioning/removed/api-version:v2/v2", (req) => {
req.expect.bodyEquals({ prop: "foo", enumProp: "enumMemberV2", unionProp: "bar" });
Expand All @@ -33,15 +12,3 @@ Scenarios.Versioning_Removed_v2 = passOnSuccess(
};
}),
);

const mockHandlers = pathsAndProperties.map(({ path, expectedBody, responseBody, status }) =>
mockapi.post(path, (req) => {
req.expect.bodyEquals(expectedBody);
return {
status,
body: json(responseBody),
};
}),
);

Scenarios.Versioning_Removed_modelV3 = passOnSuccess(mockHandlers);

0 comments on commit 73a096b

Please sign in to comment.