2022-11-28 09:59:43 +00:00
|
|
|
package config_tests
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
)
|
|
|
|
|
2023-08-15 09:58:54 +00:00
|
|
|
func TestEnvironmentOverridesWorkspaceDev(t *testing.T) {
|
2023-08-17 15:22:32 +00:00
|
|
|
b := loadTarget(t, "./environment_overrides/workspace", "development")
|
2022-11-28 09:59:43 +00:00
|
|
|
assert.Equal(t, "https://development.acme.cloud.databricks.com/", b.Config.Workspace.Host)
|
|
|
|
}
|
|
|
|
|
2023-08-15 09:58:54 +00:00
|
|
|
func TestEnvironmentOverridesWorkspaceStaging(t *testing.T) {
|
2023-08-17 15:22:32 +00:00
|
|
|
b := loadTarget(t, "./environment_overrides/workspace", "staging")
|
2022-11-28 09:59:43 +00:00
|
|
|
assert.Equal(t, "https://staging.acme.cloud.databricks.com/", b.Config.Workspace.Host)
|
|
|
|
}
|
2023-08-15 09:58:54 +00:00
|
|
|
|
|
|
|
func TestEnvironmentOverridesResourcesDev(t *testing.T) {
|
2023-08-17 15:22:32 +00:00
|
|
|
b := loadTarget(t, "./environment_overrides/resources", "development")
|
2023-08-15 09:58:54 +00:00
|
|
|
assert.Equal(t, "base job", b.Config.Resources.Jobs["job1"].Name)
|
2023-08-16 11:28:57 +00:00
|
|
|
|
|
|
|
// Base values are preserved in the development environment.
|
|
|
|
assert.Equal(t, true, b.Config.Resources.Pipelines["boolean1"].Photon)
|
|
|
|
assert.Equal(t, false, b.Config.Resources.Pipelines["boolean2"].Photon)
|
2023-08-15 09:58:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestEnvironmentOverridesResourcesStaging(t *testing.T) {
|
2023-08-17 15:22:32 +00:00
|
|
|
b := loadTarget(t, "./environment_overrides/resources", "staging")
|
2023-08-15 09:58:54 +00:00
|
|
|
assert.Equal(t, "staging job", b.Config.Resources.Jobs["job1"].Name)
|
2023-08-16 11:28:57 +00:00
|
|
|
|
|
|
|
// Overrides are only applied if they are not zero-valued.
|
|
|
|
// This means that in its current form, we cannot override a true value with a false value.
|
|
|
|
// Note: this is not desirable and will be addressed by representing our configuration
|
|
|
|
// in a different structure (e.g. with cty), instead of Go structs.
|
|
|
|
assert.Equal(t, true, b.Config.Resources.Pipelines["boolean1"].Photon)
|
|
|
|
assert.Equal(t, true, b.Config.Resources.Pipelines["boolean2"].Photon)
|
2023-08-15 09:58:54 +00:00
|
|
|
}
|