Skip to content

Commit 143fdee

Browse files
author
Yoseph Maguire
authored
Add test and fix for no options API (Azure#15455)
1 parent 6f497b5 commit 143fdee

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

sdk/iot/iot-modelsrepository/src/fetcherHTTP.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,11 @@ export class HttpFetcher implements Fetcher {
3030
this._baseURL = baseURL;
3131
}
3232

33-
async fetch(path: string, options: OperationOptions): Promise<DTDL | DTDL[]> {
33+
async fetch(path: string, options?: OperationOptions): Promise<DTDL | DTDL[]> {
3434
logger.info(`Fetching ${path} from remote endpoint`);
35+
if (!options) {
36+
options = {};
37+
}
3538
const myURL = this._baseURL + "/" + path;
3639
const requestMethod: HttpMethods = "GET";
3740
const requestHeader: HttpHeaders = createHttpHeaders(options.requestOptions?.customHeaders);

sdk/iot/iot-modelsrepository/test/node/integration/index.spec.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,29 @@ interface RemoteResolutionScenario {
2727
}
2828

2929
const remoteResolutionScenarios: RemoteResolutionScenario[] = [
30+
{
31+
name: "dependencyResolution: disabled, single DTMI, no options",
32+
clientOptions: {
33+
dependencyResolution: "disabled",
34+
repositoryLocation: "https://www.devicemodels.contoso.com"
35+
},
36+
getModelsOptions: undefined,
37+
dtmis: [
38+
{
39+
dtmi: "dtmi:contoso:FakeDeviceManagement:DeviceInformation;1",
40+
expectedUri:
41+
"https://www.devicemodels.contoso.com/dtmi/contoso/fakedevicemanagement/deviceinformation-1.json",
42+
mockedResponse: {
43+
"@id": "dtmi:contoso:FakeDeviceManagement:DeviceInformation;1",
44+
fakeDtdl: "fakeBodyAsText"
45+
},
46+
expectedOutputJson: {
47+
"@id": "dtmi:contoso:FakeDeviceManagement:DeviceInformation;1",
48+
fakeDtdl: "fakeBodyAsText"
49+
}
50+
}
51+
]
52+
},
3053
{
3154
name: "dependencyResolution: disabled, single DTMI, no dependencies",
3255
clientOptions: {

0 commit comments

Comments
 (0)