Skip to content

Commit

Permalink
test: Process target mode
Browse files Browse the repository at this point in the history
  • Loading branch information
ilyakuz-db committed Nov 15, 2024
1 parent 8cd95eb commit e9b7289
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
2 changes: 1 addition & 1 deletion bundle/config/mutator/apply_presets_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
29 changes: 29 additions & 0 deletions bundle/config/mutator/process_target_mode_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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/[email protected]/"
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
}

0 comments on commit e9b7289

Please sign in to comment.