Skip to content

Commit e13d9a1

Browse files
author
Kartik Raj
committed
Code review bug
1 parent d61f44e commit e13d9a1

File tree

5 files changed

+13
-11
lines changed

5 files changed

+13
-11
lines changed

src/client/common/insidersBuild/downloadChannelService.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@ export class ExtensionChannelService implements IExtensionChannelService {
2727
this.isThisFirstSessionState = this.persistentStateFactory.createGlobalPersistentState(isThisFirstSessionStateKey, true);
2828
disposables.push(this.workspaceService.onDidChangeConfiguration(this.onDidChangeConfiguration.bind(this)));
2929
}
30-
public get channel(): ExtensionChannels {
30+
public async getChannel(): Promise<ExtensionChannels> {
3131
const settings = this.workspaceService.getConfiguration('python').inspect<ExtensionChannels>(insidersChannelSetting);
3232
if (!settings) {
3333
throw new Error(`WorkspaceConfiguration.inspect returns 'undefined' for setting 'python.${insidersChannelSetting}'`);
3434
}
3535
if (settings.globalValue === undefined) {
3636
const isThisFirstSession = this.isThisFirstSessionState.value;
37-
this.isThisFirstSessionState.updateValue(false);
37+
await this.isThisFirstSessionState.updateValue(false);
3838
// "Official" VSC default setting value is stable. To keep the official value to be in sync with what is being used,
3939
// Use Insiders default as 'InsidersWeekly' only for the first session (insiders gets installed for the first session).
4040
return this.appEnvironment.channel === 'insiders' && isThisFirstSession ? ExtensionChannel.insidersDefaultForTheFirstSession : 'Stable';

src/client/common/insidersBuild/insidersExtensionService.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export class InsidersExtensionService implements IExtensionActivationService {
3030
}
3131
this.registerCommandsAndHandlers();
3232
this.activatedOnce = true;
33-
const installChannel = this.extensionChannelService.channel;
33+
const installChannel = await this.extensionChannelService.getChannel();
3434
const newExtensionChannel: Channel = installChannel === 'Stable' ? 'stable' : 'insiders';
3535
this.handleChannel(installChannel, newExtensionChannel !== this.appEnvironment.extensionChannel).ignoreErrors();
3636
}

src/client/common/insidersBuild/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export interface IExtensionChannelRule {
1515
export const IExtensionChannelService = Symbol('IExtensionChannelService');
1616
export interface IExtensionChannelService {
1717
readonly onDidChannelChange: Event<ExtensionChannels>;
18-
readonly channel: ExtensionChannels;
18+
getChannel(): Promise<ExtensionChannels>;
1919
updateChannel(value: ExtensionChannels): Promise<void>;
2020
}
2121

src/test/common/insidersBuild/downloadChannelService.unit.test.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,8 @@ suite('Download channel service', () => {
9292
.setup(u => u.updateValue(false))
9393
.returns(() => Promise.resolve());
9494
when(appEnvironment.channel).thenReturn(testParams.vscodeChannel as any);
95-
expect(channelService.channel).to.equal(testParams.expectedResult);
95+
const channel = await channelService.getChannel();
96+
expect(channel).to.equal(testParams.expectedResult);
9697
workspaceConfig.verifyAll();
9798
});
9899
});
@@ -114,7 +115,8 @@ suite('Download channel service', () => {
114115
.setup(u => u.updateValue(false))
115116
.returns(() => Promise.resolve());
116117
when(appEnvironment.channel).thenReturn('insiders');
117-
expect(channelService.channel).to.equal('Stable');
118+
const channel = await channelService.getChannel();
119+
expect(channel).to.equal('Stable');
118120
workspaceConfig.verifyAll();
119121
});
120122

@@ -128,7 +130,7 @@ suite('Download channel service', () => {
128130
workspaceConfig.setup(c => c.inspect<ExtensionChannels>(insidersChannelSetting))
129131
.returns(() => settings as any)
130132
.verifiable(TypeMoq.Times.once());
131-
expect(() => channelService.channel).to.throw();
133+
await expect(channelService.getChannel()).to.eventually.be.rejected;
132134
workspaceConfig.verifyAll();
133135
});
134136

src/test/common/insidersBuild/insidersExtensionService.unit.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -157,11 +157,11 @@ suite('Insiders Extension Service - Activation', () => {
157157
handleChannel = sinon.stub(InsidersExtensionService.prototype, 'handleChannel');
158158
handleChannel.callsFake(() => Promise.resolve());
159159
insidersExtensionService = new InsidersExtensionService(instance(extensionChannelService), instance(insidersPrompt), instance(appEnvironment), instance(cmdManager), instance(serviceContainer), []);
160-
when(extensionChannelService.channel).thenReturn(testParams.installChannel);
160+
when(extensionChannelService.getChannel()).thenResolve(testParams.installChannel);
161161
when(appEnvironment.extensionChannel).thenReturn(testParams.extensionChannel);
162162
await insidersExtensionService.activate(Uri.parse('r'));
163163
expect(handleChannel.args[0][1]).to.equal(testParams.expectedResult);
164-
verify(extensionChannelService.channel).once();
164+
verify(extensionChannelService.getChannel()).once();
165165
verify(appEnvironment.extensionChannel).once();
166166
expect(insidersExtensionService.activatedOnce).to.equal(true, 'Variable should be set to true');
167167
});
@@ -172,7 +172,7 @@ suite('Insiders Extension Service - Activation', () => {
172172
handleChannel = sinon.stub(InsidersExtensionService.prototype, 'handleChannel');
173173
handleChannel.callsFake(() => handleChannelsDeferred.promise);
174174
insidersExtensionService = new InsidersExtensionService(instance(extensionChannelService), instance(insidersPrompt), instance(appEnvironment), instance(cmdManager), instance(serviceContainer), []);
175-
when(extensionChannelService.channel).thenReturn('InsidersDaily');
175+
when(extensionChannelService.getChannel()).thenResolve('InsidersDaily');
176176
when(appEnvironment.extensionChannel).thenReturn('insiders');
177177

178178
const promise = insidersExtensionService.activate(Uri.parse('r'));
@@ -185,7 +185,7 @@ suite('Insiders Extension Service - Activation', () => {
185185
handleChannelsDeferred.resolve();
186186
await sleep(1);
187187

188-
verify(extensionChannelService.channel).once();
188+
verify(extensionChannelService.getChannel()).once();
189189
verify(appEnvironment.extensionChannel).once();
190190
expect(insidersExtensionService.activatedOnce).to.equal(true, 'Variable should be set to true');
191191
});

0 commit comments

Comments
 (0)