mirror of https://github.com/databricks/cli.git
Add tests
This commit is contained in:
parent
153510bfbf
commit
feb77686b5
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
}
|
Loading…
Reference in New Issue