Skip to content

Commit 2ee6693

Browse files
committed
Add regression tests for unified-host account profiles
Table-driven tests for isAccountLevelConfig covering classic account host, unified host with/without account ID, workspace host, and missing host. Also adds a test for checkIdentity skipping the /me endpoint for unified-host account profiles. Co-authored-by: Isaac
1 parent ce26292 commit 2ee6693

1 file changed

Lines changed: 71 additions & 0 deletions

File tree

cmd/doctor/doctor_test.go

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,77 @@ func TestCheckIdentitySkippedForAccountLevel(t *testing.T) {
357357
assert.Contains(t, result.Message, "account-level")
358358
}
359359

360+
func TestIsAccountLevelConfig(t *testing.T) {
361+
tests := []struct {
362+
name string
363+
cfg *config.Config
364+
want bool
365+
}{
366+
{
367+
name: "classic account host",
368+
cfg: &config.Config{
369+
Host: "https://accounts.cloud.databricks.com",
370+
AccountID: "test-account-123",
371+
},
372+
want: true,
373+
},
374+
{
375+
name: "unified host with account ID",
376+
cfg: &config.Config{
377+
Host: "https://myhost.databricks.com",
378+
AccountID: "test-account-123",
379+
Experimental_IsUnifiedHost: true,
380+
},
381+
want: true,
382+
},
383+
{
384+
name: "unified host without account ID is workspace",
385+
cfg: &config.Config{
386+
Host: "https://myhost.databricks.com",
387+
Experimental_IsUnifiedHost: true,
388+
},
389+
want: false,
390+
},
391+
{
392+
name: "workspace host",
393+
cfg: &config.Config{
394+
Host: "https://myhost.databricks.com",
395+
},
396+
want: false,
397+
},
398+
{
399+
name: "no host",
400+
cfg: &config.Config{
401+
AccountID: "test-account-123",
402+
},
403+
want: false,
404+
},
405+
}
406+
407+
for _, tt := range tests {
408+
t.Run(tt.name, func(t *testing.T) {
409+
assert.Equal(t, tt.want, isAccountLevelConfig(tt.cfg))
410+
})
411+
}
412+
}
413+
414+
func TestCheckIdentitySkippedForUnifiedHostAccount(t *testing.T) {
415+
cfg := &config.Config{
416+
Host: "https://myhost.databricks.com",
417+
AccountID: "test-account-123",
418+
Token: "test-token",
419+
Experimental_IsUnifiedHost: true,
420+
}
421+
422+
ctx := cmdio.MockDiscard(t.Context())
423+
cmd := newTestCmd(ctx)
424+
425+
result := checkIdentity(cmd, cfg)
426+
assert.Equal(t, "Identity", result.Name)
427+
assert.Equal(t, statusSkip, result.Status)
428+
assert.Contains(t, result.Message, "account-level")
429+
}
430+
360431
func TestCheckNetworkReachable(t *testing.T) {
361432
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
362433
w.WriteHeader(http.StatusOK)

0 commit comments

Comments
 (0)