зеркало из https://github.com/Azure/cadl-ranch.git
fix(mockapi): dotnet compatibility failure (#769)
* fix(mockapi): dotnet compatibility failure dotnet uses different but compatible datetime format, so the comparison should use `coercedBodyEquals` --------- Co-authored-by: Mingzhe Huang (from Dev Box) <mingzhehuang@microsoft.com>
This commit is contained in:
Родитель
778bacc545
Коммит
bb6a2dd9d1
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
"@azure-tools/cadl-ranch-specs": patch
|
||||
---
|
||||
|
||||
Fix dotnet compatibility issues in MockApi
|
|
@ -23,6 +23,12 @@ function createServerTests(uri: string, data: any) {
|
|||
response: {
|
||||
status: 204,
|
||||
},
|
||||
handler: (req) => {
|
||||
req.expect.coercedBodyEquals(data);
|
||||
return {
|
||||
status: 204,
|
||||
};
|
||||
},
|
||||
kind: "MockApiDefinition",
|
||||
}),
|
||||
};
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { passOnSuccess, ScenarioMockApi, json } from "@azure-tools/cadl-ranch-api";
|
||||
import { passOnSuccess, ScenarioMockApi, json, MockRequest } from "@azure-tools/cadl-ranch-api";
|
||||
|
||||
export const Scenarios: Record<string, ScenarioMockApi> = {};
|
||||
|
||||
|
@ -119,6 +119,13 @@ function createServerTests(url: string, value: any) {
|
|||
response: {
|
||||
status: 204,
|
||||
},
|
||||
handler: (req: MockRequest) => {
|
||||
const expectedBody = JSON.parse(JSON.stringify(value));
|
||||
req.expect.coercedBodyEquals(expectedBody);
|
||||
return {
|
||||
status: 204,
|
||||
};
|
||||
},
|
||||
kind: "MockApiDefinition",
|
||||
}),
|
||||
};
|
||||
|
|
|
@ -29,6 +29,15 @@ function createServerTests(url: string, value: unknown, patchNullableProperty?:
|
|||
response: {
|
||||
status: 204,
|
||||
},
|
||||
handler: (req) => {
|
||||
req.expect.coercedBodyEquals({
|
||||
requiredProperty: "foo",
|
||||
nullableProperty: patchNullableProperty || null,
|
||||
});
|
||||
return {
|
||||
status: 204,
|
||||
};
|
||||
},
|
||||
kind: "MockApiDefinition",
|
||||
}),
|
||||
};
|
||||
|
|
|
@ -23,6 +23,12 @@ function createServerTests(url: string, value: unknown) {
|
|||
response: {
|
||||
status: 204,
|
||||
},
|
||||
handler: (req) => {
|
||||
req.expect.coercedBodyEquals(value);
|
||||
return {
|
||||
status: 204,
|
||||
};
|
||||
},
|
||||
kind: "MockApiDefinition",
|
||||
}),
|
||||
};
|
||||
|
|
|
@ -23,6 +23,12 @@ function createServerTests(url: string, data: unknown, convertedToFn?: (_: any)
|
|||
response: {
|
||||
status: 204,
|
||||
},
|
||||
handler: (req) => {
|
||||
req.expect.coercedBodyEquals(data);
|
||||
return {
|
||||
status: 204,
|
||||
};
|
||||
},
|
||||
kind: "MockApiDefinition",
|
||||
}),
|
||||
};
|
||||
|
|
Загрузка…
Ссылка в новой задаче