Skip to content

Commit f9d041d

Browse files
committed
Add integration test for host metadata resolution
Port of Python SDK PR #1332. Verifies that EnsureResolved with Experimental_IsUnifiedHost populates account_id and workspace_id from the host metadata endpoint on workspace environments. Co-authored-by: Isaac
1 parent 0e20fea commit f9d041d

1 file changed

Lines changed: 31 additions & 0 deletions

File tree

internal/host_metadata_test.go

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package internal
2+
3+
import (
4+
"testing"
5+
6+
"github.com/databricks/databricks-sdk-go/config"
7+
"github.com/stretchr/testify/assert"
8+
"github.com/stretchr/testify/require"
9+
)
10+
11+
func TestHostMetadataResolution(t *testing.T) {
12+
loadDebugEnvIfRunsFromIDE(t, "workspace")
13+
t.Log(GetEnvOrSkipTest(t, "CLOUD_ENV"))
14+
envType := testEnvironmentType()
15+
if envType != "" {
16+
if envType != "WORKSPACE" && envType != "UC_WORKSPACE" {
17+
skipf(t)("Skipping workspace test: TEST_ENVIRONMENT_TYPE=%s", envType)
18+
}
19+
}
20+
t.Parallel()
21+
22+
cfg := &config.Config{
23+
Experimental_IsUnifiedHost: true,
24+
}
25+
err := cfg.EnsureResolved()
26+
require.NoError(t, err)
27+
28+
assert.NotEmpty(t, cfg.AccountID, "expected account_id to be resolved from host metadata")
29+
// Workspace hosts should always have a workspace_id in metadata.
30+
assert.NotEmpty(t, cfg.WorkspaceID, "expected workspace_id to be resolved from host metadata")
31+
}

0 commit comments

Comments
 (0)