Skip to content

Commit

Permalink
Merge branch 'main' into mgmt_testcases
Browse files Browse the repository at this point in the history
  • Loading branch information
XiaofeiCao authored Jun 18, 2024
2 parents 4243fe4 + d983279 commit 96ad5d9
Show file tree
Hide file tree
Showing 4 changed files with 126 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/shaggy-turkeys-applaud.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@azure-tools/cadl-ranch-specs": patch
---

Add nullable int/string/boolean/model test cases for Type/Array
80 changes: 80 additions & 0 deletions packages/cadl-ranch-specs/cadl-ranch-summary.md
Original file line number Diff line number Diff line change
Expand Up @@ -3770,6 +3770,26 @@ Expected Array input body:
[{ "property": "hello" }, { "property": "world" }]
```

### Type_Array_NullableBooleanValue_get

- Endpoint: `get /type/array/nullable-boolean`

Expected Array response body:

```json
[true, null, false]
```

### Type_Array_NullableBooleanValue_put

- Endpoint: `put /type/array/nullable-boolean`

Expected Array input body:

```json
[true, null, false]
```

### Type_Array_NullableFloatValue_get

- Endpoint: `get /type/array/nullable-float`
Expand All @@ -3790,6 +3810,66 @@ Expected Array input body:
[1.25, null, 3.0]
```

### Type_Array_NullableInt32Value_get

- Endpoint: `get /type/array/nullable-int32`

Expected Array response body:

```json
[1, null, 3]
```

### Type_Array_NullableInt32Value_put

- Endpoint: `put /type/array/nullable-int32`

Expected Array input body:

```json
[1, null, 3]
```

### Type_Array_NullableModelValue_get

- Endpoint: `get /type/array/nullable-model`

Expected Array response body:

```json
[{ "property": "hello" }, null, { "property": "world" }]
```

### Type_Array_NullableModelValue_put

- Endpoint: `put /type/array/nullable-model`

Expected Array input body:

```json
[{ "property": "hello" }, null, { "property": "world" }]
```

### Type_Array_NullableStringValue_get

- Endpoint: `get /type/array/nullable-string`

Expected Array response body:

```json
["hello", null, "world"]
```

### Type_Array_NullableStringValue_put

- Endpoint: `put /type/array/nullable-string`

Expected Array input body:

```json
["hello", null, "world"]
```

### Type_Array_StringValue_get

- Endpoint: `get /type/array/string`
Expand Down
25 changes: 25 additions & 0 deletions packages/cadl-ranch-specs/http/type/array/main.tsp
Original file line number Diff line number Diff line change
Expand Up @@ -100,3 +100,28 @@ alias NullableFloat = float32 | null;
@route("/nullable-float")
@operationGroup
interface NullableFloatValue extends ArrayOperations<NullableFloat[], "[1.25, null, 3.0]"> {}

alias NullableInt32 = int32 | null;
@doc("Array of nullable int32 values")
@route("/nullable-int32")
@operationGroup
interface NullableInt32Value extends ArrayOperations<NullableInt32[], "[1, null, 3]"> {}

alias NullableBoolean = boolean | null;
@doc("Array of nullable boolean values")
@route("/nullable-boolean")
@operationGroup
interface NullableBooleanValue extends ArrayOperations<NullableBoolean[], "[true, null, false]"> {}

alias NullableString = string | null;
@doc("Array of nullable string values")
@route("/nullable-string")
@operationGroup
interface NullableStringValue extends ArrayOperations<NullableString[], "['hello', null, 'world']"> {}

alias NullableModel = InnerModel | null;
@doc("Array of nullable model values")
@route("/nullable-model")
@operationGroup
interface NullableModelValue
extends ArrayOperations<NullableModel[], "[{'property': 'hello'}, null, {'property': 'world'}]"> {}
16 changes: 16 additions & 0 deletions packages/cadl-ranch-specs/http/type/array/mockapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,19 @@ Scenarios.Type_Array_ModelValue_put = passOnSuccess(ModelValueMock.put);
const NullableFloatMock = createModelMockApis("nullable-float", [1.25, null, 3.0]);
Scenarios.Type_Array_NullableFloatValue_get = passOnSuccess(NullableFloatMock.get);
Scenarios.Type_Array_NullableFloatValue_put = passOnSuccess(NullableFloatMock.put);

const NullableInt32Mock = createModelMockApis("nullable-int32", [1, null, 3]);
Scenarios.Type_Array_NullableInt32Value_get = passOnSuccess(NullableInt32Mock.get);
Scenarios.Type_Array_NullableInt32Value_put = passOnSuccess(NullableInt32Mock.put);

const NullableStringMock = createModelMockApis("nullable-string", ["hello", null, "world"]);
Scenarios.Type_Array_NullableStringValue_get = passOnSuccess(NullableStringMock.get);
Scenarios.Type_Array_NullableStringValue_put = passOnSuccess(NullableStringMock.put);

const NullableBooleanMock = createModelMockApis("nullable-boolean", [true, null, false]);
Scenarios.Type_Array_NullableBooleanValue_get = passOnSuccess(NullableBooleanMock.get);
Scenarios.Type_Array_NullableBooleanValue_put = passOnSuccess(NullableBooleanMock.put);

const NullableModelMock = createModelMockApis("nullable-model", [{ property: "hello" }, null, { property: "world" }]);
Scenarios.Type_Array_NullableModelValue_get = passOnSuccess(NullableModelMock.get);
Scenarios.Type_Array_NullableModelValue_put = passOnSuccess(NullableModelMock.put);

0 comments on commit 96ad5d9

Please sign in to comment.