diff --git a/bundle/config/mutator/validate_workspace_host.go b/bundle/config/mutator/validate_workspace_host.go index 3ffb27b9..5450ab96 100644 --- a/bundle/config/mutator/validate_workspace_host.go +++ b/bundle/config/mutator/validate_workspace_host.go @@ -23,7 +23,7 @@ func (m *validateWorkspaceHost) Apply(ctx context.Context, b *bundle.Bundle) dia target_host := b.Config.Workspace.Host if env_host != "" && target_host != "" && env_host != target_host { - return diag.Errorf("Target host and DATABRICKS_HOST environment variable mismatch") + return diag.Errorf("target host and DATABRICKS_HOST environment variable mismatch") } return nil diff --git a/bundle/config/mutator/validate_workspace_host_test.go b/bundle/config/mutator/validate_workspace_host_test.go new file mode 100644 index 00000000..718d2dac --- /dev/null +++ b/bundle/config/mutator/validate_workspace_host_test.go @@ -0,0 +1,43 @@ +package mutator + +import ( + "context" + "testing" + + "github.com/databricks/cli/bundle" + "github.com/databricks/cli/bundle/config" + "github.com/databricks/cli/bundle/env" + "github.com/stretchr/testify/assert" +) + +func TestValidateValidateWorkspaceHost(t *testing.T) { + host := "https://host.databricks.com" + b := &bundle.Bundle{ + Config: config.Root{ + Workspace: config.Workspace{ + Host: host, + }, + }, + } + t.Setenv(env.HostVariable, host) + + m := ValidateWorkspaceHost() + diags := bundle.Apply(context.Background(), b, m) + assert.NoError(t, diags.Error()) +} + +func TestValidateValidateWorkspaceHostMismatch(t *testing.T) { + b := &bundle.Bundle{ + Config: config.Root{ + Workspace: config.Workspace{ + Host: "https://target-host.databricks.com", + }, + }, + } + t.Setenv(env.HostVariable, "https://env-host.databricks.com") + + m := ValidateWorkspaceHost() + diags := bundle.Apply(context.Background(), b, m) + expectedError := "target host and DATABRICKS_HOST environment variable mismatch" + assert.EqualError(t, diags.Error(), expectedError) +}