Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions src/cmd/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ module.exports = class ParticleApi {
}));
}

performEnvRollout({ org, productId, deviceId, when = 'connect' }) {
performEnvRollout({ org, productId, deviceId, when = 'Connect' }) {
const uri = getRolloutUri({ org, productId, deviceId });
return this._wrap(this.api.request({
uri,
Expand Down Expand Up @@ -589,10 +589,8 @@ function getRolloutUri({ org, productId, deviceId }) {
uri = `/v1/orgs/${org}/env-vars/rollout`;
} else if (productId) {
uri = `/v1/products/${productId}/env-vars/rollout`;
} else if (deviceId) {
uri = `/v1/devices/${deviceId}/env-vars/rollout`;
} else {
uri = '/v1/env-vars/rollout';
uri = `/v1/env-vars${deviceId ? `/${deviceId}` : ''}/rollout`;
}
return uri;
}
Expand Down
14 changes: 7 additions & 7 deletions src/cmd/api.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ describe('ParticleApi', () => {

it('should call the correct API endpoint for device rollout', async () => {
const deviceId = 'testDeviceId';
const expectedUri = `/v1/devices/${deviceId}/env-vars/rollout`;
const expectedUri = `/v1/env-vars/${deviceId}/rollout`;
const expectedResponse = { body: { some: 'sandbox-device-data' } };

const requestStub = sandbox.stub(particleApi.api, 'request').resolves(expectedResponse);
Expand Down Expand Up @@ -116,7 +116,7 @@ describe('ParticleApi', () => {
uri: expectedUri,
method: 'post',
auth: 'test-token',
data: { when: 'connect' }
data: { when: 'Connect' }
});
expect(result).to.deep.equal(expectedResponse.body);
});
Expand All @@ -134,7 +134,7 @@ describe('ParticleApi', () => {
uri: expectedUri,
method: 'post',
auth: 'test-token',
data: { when: 'connect' }
data: { when: 'Connect' }
});
expect(result).to.deep.equal(expectedResponse.body);
});
Expand All @@ -151,25 +151,25 @@ describe('ParticleApi', () => {
uri: expectedUri,
method: 'post',
auth: 'test-token',
data: { when: 'connect' }
data: { when: 'Connect' }
});
expect(result).to.deep.equal(expectedResponse.body);
});

it('calls the correct API endpoint for device rollout', async () => {
const deviceId = 'testDeviceId';
const expectedUri = `/v1/devices/${deviceId}/env-vars/rollout`;
const expectedUri = `/v1/env-vars/${deviceId}/rollout`;
const expectedResponse = { body: { some: 'sandbox-device-data' } };

const requestStub = sandbox.stub(particleApi.api, 'request').resolves(expectedResponse);

const result = await particleApi.performEnvRollout({ deviceId, when: 'immediate' });
const result = await particleApi.performEnvRollout({ deviceId, when: 'Immediate' });

expect(requestStub).to.have.been.calledWithMatch({
uri: expectedUri,
method: 'post',
auth: 'test-token',
data: { when: 'immediate' }
data: { when: 'Immediate' }
});
expect(result).to.deep.equal(expectedResponse.body);
});
Expand Down