Skip to content

Commit 12f0532

Browse files
committed
Add test for GetWorkspaceClient with SPOG host
Port of Go SDK #1518. Verifies that getWorkspaceClient() on a unified (SPOG) host clones the config rather than mutating the AccountClient's config, so multiple calls produce independent WorkspaceClients. Co-authored-by: Isaac
1 parent b666e40 commit 12f0532

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

databricks-sdk-java/src/test/java/com/databricks/sdk/AccountClientTest.java

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,4 +72,40 @@ public void testGetWorkspaceClientForUnifiedHostType() {
7272

7373
assertEquals(HostType.UNIFIED, config.getHostType());
7474
}
75+
76+
@Test
77+
public void testGetWorkspaceClientForSpogHostDoesNotMutateAccountConfig() {
78+
String spogHost = "https://mycompany.databricks.com";
79+
DatabricksConfig accountConfig =
80+
new DatabricksConfig()
81+
.setHost(spogHost)
82+
.setExperimentalIsUnifiedHost(true)
83+
.setAccountId("test-account")
84+
.setToken("test-token");
85+
86+
AccountClient accountClient = new AccountClient(accountConfig);
87+
88+
// Get workspace client for first workspace
89+
Workspace workspace1 = new Workspace();
90+
workspace1.setWorkspaceId(111L);
91+
workspace1.setDeploymentName("ws-1");
92+
WorkspaceClient wc1 = accountClient.getWorkspaceClient(workspace1);
93+
94+
// Get workspace client for second workspace
95+
Workspace workspace2 = new Workspace();
96+
workspace2.setWorkspaceId(222L);
97+
workspace2.setDeploymentName("ws-2");
98+
WorkspaceClient wc2 = accountClient.getWorkspaceClient(workspace2);
99+
100+
// Each workspace client should have its own workspace ID
101+
assertEquals("111", wc1.config().getWorkspaceId());
102+
assertEquals("222", wc2.config().getWorkspaceId());
103+
104+
// Account config should not have been mutated
105+
assertNull(accountConfig.getWorkspaceId());
106+
107+
// Both should share the same SPOG host
108+
assertEquals(spogHost, wc1.config().getHost());
109+
assertEquals(spogHost, wc2.config().getHost());
110+
}
75111
}

0 commit comments

Comments
 (0)