test: Process target mode

This commit is contained in:
Ilya Kuznetsov 2024-11-15 12:32:44 +01:00
parent 8cd95eb0ea
commit e9b72895dc
No known key found for this signature in database
GPG Key ID: 91F3DDCF5D21CDDF
2 changed files with 30 additions and 1 deletions

View File

@ -374,7 +374,7 @@ func TestApplyPresetsResourceNotDefined(t *testing.T) {
}
func TestApplyPresetsInPlaceDeployment(t *testing.T) {
testContext := context.TODO()
testContext := context.Background()
enabled := true
disabled := false
remotePath := "/Users/files"

View File

@ -9,6 +9,7 @@ import (
"github.com/databricks/cli/bundle"
"github.com/databricks/cli/bundle/config"
"github.com/databricks/cli/bundle/config/resources"
"github.com/databricks/cli/libs/dbr"
"github.com/databricks/cli/libs/diag"
"github.com/databricks/cli/libs/tags"
"github.com/databricks/cli/libs/vfs"
@ -517,3 +518,31 @@ func TestPipelinesDevelopmentDisabled(t *testing.T) {
assert.False(t, b.Config.Resources.Pipelines["pipeline1"].PipelineSpec.Development)
}
func TestInPlaceDeploymentEnabled(t *testing.T) {
b, diags := processInPlaceBundle(true)
require.NoError(t, diags.Error())
assert.True(t, *b.Config.Presets.InPlaceDeployment)
assert.Equal(t, b.Config.Workspace.FilePath, b.SyncRootPath)
}
func TestInPlaceDeploymentDisabled(t *testing.T) {
b, diags := processInPlaceBundle(false)
require.NoError(t, diags.Error())
assert.False(t, *b.Config.Presets.InPlaceDeployment)
assert.NotEqual(t, b.Config.Workspace.FilePath, b.SyncRootPath)
}
func processInPlaceBundle(presetEnabled bool) (*bundle.Bundle, diag.Diagnostics) {
b := mockBundle(config.Development)
workspacePath := "/Workspace/lennart@company.com/"
b.SyncRoot = vfs.MustNew(workspacePath)
b.SyncRootPath = workspacePath
b.Config.Presets.InPlaceDeployment = &presetEnabled
ctx := dbr.MockRuntime(context.Background(), true)
m := bundle.Seq(ProcessTargetMode(), ApplyPresets())
diags := bundle.Apply(ctx, b, m)
return b, diags
}