Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit db0049d

Browse filesBrowse files
Akos Kittakittaakos
Akos Kitta
authored andcommitted
fix: omit port from upload request when not set
Previously, if the `port` was not set in IDE2, the compile request object has been created with an empty port object (`{}`). From now on, if the port is not specified, IDE2 will create a compile request with the default `null` `port` value. Closes #2089 Signed-off-by: Akos Kitta <a.kitta@arduino.cc>
1 parent 0fbd1fb commit db0049d
Copy full SHA for db0049d

File tree

2 files changed

+55
-10
lines changed
Filter options

2 files changed

+55
-10
lines changed

‎arduino-ide-extension/src/node/core-service-impl.ts

Copy file name to clipboardExpand all lines: arduino-ide-extension/src/node/core-service-impl.ts
+14-10Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -411,17 +411,21 @@ export class CoreServiceImpl extends CoreClientAware implements CoreService {
411411
}
412412
}
413413

414-
private createPort(port: Port | undefined): RpcPort {
414+
private createPort(port: Port | undefined): RpcPort | undefined {
415+
if (!port) {
416+
return undefined;
417+
}
415418
const rpcPort = new RpcPort();
416-
if (port) {
417-
rpcPort.setAddress(port.address);
418-
rpcPort.setLabel(port.addressLabel);
419-
rpcPort.setProtocol(port.protocol);
420-
rpcPort.setProtocolLabel(port.protocolLabel);
421-
if (port.properties) {
422-
for (const [key, value] of Object.entries(port.properties)) {
423-
rpcPort.getPropertiesMap().set(key, value);
424-
}
419+
rpcPort.setAddress(port.address);
420+
rpcPort.setLabel(port.addressLabel);
421+
rpcPort.setProtocol(port.protocol);
422+
rpcPort.setProtocolLabel(port.protocolLabel);
423+
if (port.hardwareId !== undefined) {
424+
rpcPort.setHardwareId(port.hardwareId);
425+
}
426+
if (port.properties) {
427+
for (const [key, value] of Object.entries(port.properties)) {
428+
rpcPort.getPropertiesMap().set(key, value);
425429
}
426430
}
427431
return rpcPort;
+41Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import { expect } from 'chai';
2+
import { Port } from '../../node/cli-protocol/cc/arduino/cli/commands/v1/port_pb';
3+
import { CoreServiceImpl } from '../../node/core-service-impl';
4+
5+
describe('core-service-impl', () => {
6+
describe('createPort', () => {
7+
it("should map the 'undefined' port object to an 'undefined' gRPC port value", () => {
8+
const actual = new CoreServiceImpl()['createPort'](undefined);
9+
expect(actual).to.be.undefined;
10+
});
11+
12+
it('should map a port object to the appropriate gRPC port object', () => {
13+
const properties = {
14+
alma: 'false',
15+
korte: '36',
16+
};
17+
const port = {
18+
address: 'address',
19+
addressLabel: 'address label',
20+
hardwareId: '1730323',
21+
protocol: 'serial',
22+
protocolLabel: 'serial port',
23+
properties,
24+
} as const;
25+
const actual = new CoreServiceImpl()['createPort'](port);
26+
expect(actual).to.be.not.undefined;
27+
const expected = new Port()
28+
.setAddress(port.address)
29+
.setHardwareId(port.hardwareId)
30+
.setLabel(port.addressLabel)
31+
.setProtocol(port.protocol)
32+
.setProtocolLabel(port.protocolLabel);
33+
Object.entries(properties).forEach(([key, value]) =>
34+
expected.getPropertiesMap().set(key, value)
35+
);
36+
expect((<Port>actual).toObject(false)).to.be.deep.equal(
37+
expected.toObject(false)
38+
);
39+
});
40+
});
41+
});

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.