Skip to content

Commit 96192cb

Browse files
authored
Mock settings writes in ToolchainSelection tests (#1829)
The `should show open dialog for folder selection` test would write the selected toolchain value into settings. This would break the integration tests if you ran them after the unit tests because the location of `swift` would be incorrect.
1 parent cafa742 commit 96192cb

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

test/unit-tests/ui/ToolchainSelection.test.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ suite("ToolchainSelection Unit Test Suite", () => {
3232
const mockedVSCodeWindow = mockGlobalObject(vscode, "window");
3333
const mockedVSCodeCommands = mockGlobalObject(vscode, "commands");
3434
const mockedVSCodeEnv = mockGlobalObject(vscode, "env");
35+
const mockedVSCodeWorkspace = mockGlobalObject(vscode, "workspace");
3536
let mockLogger: SwiftLogger;
3637

3738
setup(() => {
@@ -57,6 +58,15 @@ suite("ToolchainSelection Unit Test Suite", () => {
5758
mockedVSCodeCommands.executeCommand.resolves(undefined);
5859
mockedVSCodeEnv.openExternal.resolves(true);
5960

61+
// Mock workspace configuration to prevent actual settings writes
62+
const mockConfiguration = {
63+
update: stub().resolves(),
64+
inspect: stub().returns({}),
65+
get: stub().returns(undefined),
66+
has: stub().returns(false),
67+
};
68+
mockedVSCodeWorkspace.getConfiguration.returns(mockConfiguration);
69+
6070
// Mock SwiftToolchain static methods
6171
stub(SwiftToolchain, "findXcodeInstalls").resolves([]);
6272
stub(SwiftToolchain, "getToolchainInstalls").resolves([]);

0 commit comments

Comments
 (0)