|
3 | 3 | import static org.junit.jupiter.api.Assertions.*; |
4 | 4 |
|
5 | 5 | import com.databricks.sdk.core.utils.Environment; |
| 6 | +import java.io.IOException; |
6 | 7 | import java.util.*; |
7 | 8 | import java.util.stream.Stream; |
8 | 9 | import org.junit.jupiter.api.Test; |
@@ -96,18 +97,20 @@ public void testIsAccountClientForNonAccountsHost() { |
96 | 97 | // --- Environment Variable Tests --- |
97 | 98 |
|
98 | 99 | @Test |
99 | | - public void testWorkspaceIdFromEnvironmentVariables() { |
100 | | - Map<String, String> env = new HashMap<>(); |
101 | | - env.put("DATABRICKS_HOST", "https://mycompany.databricks.com"); |
102 | | - env.put("DATABRICKS_WORKSPACE_ID", "987654321"); |
103 | | - env.put("DATABRICKS_ACCOUNT_ID", "account-abc"); |
104 | | - |
105 | | - DatabricksConfig config = new DatabricksConfig(); |
106 | | - config.resolve(new Environment(env, new ArrayList<>(), System.getProperty("os.name"))); |
107 | | - |
108 | | - assertEquals(HostType.WORKSPACE, config.getHostType()); |
109 | | - assertEquals("987654321", config.getWorkspaceId()); |
110 | | - assertEquals("account-abc", config.getAccountId()); |
111 | | - assertEquals(ClientType.WORKSPACE, config.getClientType()); |
| 100 | + public void testWorkspaceIdFromEnvironmentVariables() throws IOException { |
| 101 | + try (FixtureServer server = new FixtureServer()) { |
| 102 | + Map<String, String> env = new HashMap<>(); |
| 103 | + env.put("DATABRICKS_HOST", server.getUrl()); |
| 104 | + env.put("DATABRICKS_WORKSPACE_ID", "987654321"); |
| 105 | + env.put("DATABRICKS_ACCOUNT_ID", "account-abc"); |
| 106 | + |
| 107 | + DatabricksConfig config = new DatabricksConfig(); |
| 108 | + config.resolve(new Environment(env, new ArrayList<>(), System.getProperty("os.name"))); |
| 109 | + |
| 110 | + assertEquals(HostType.WORKSPACE, config.getHostType()); |
| 111 | + assertEquals("987654321", config.getWorkspaceId()); |
| 112 | + assertEquals("account-abc", config.getAccountId()); |
| 113 | + assertEquals(ClientType.WORKSPACE, config.getClientType()); |
| 114 | + } |
112 | 115 | } |
113 | 116 | } |
0 commit comments