Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
pietern committed Mar 22, 2024
1 parent 8f65288 commit fa7c64e
Show file tree
Hide file tree
Showing 34 changed files with 11 additions and 73 deletions.
1 change: 0 additions & 1 deletion bundle/config/mutator/expand_workspace_root_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ func TestExpandWorkspaceRoot(t *testing.T) {
}
diags := bundle.Apply(context.Background(), b, mutator.ExpandWorkspaceRoot())
require.Empty(t, diags)

assert.Equal(t, "/Users/[email protected]/foo", b.Config.Workspace.RootPath)
}

Expand Down
2 changes: 0 additions & 2 deletions bundle/config/mutator/initialize_variables_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ func TestInitializeVariables(t *testing.T) {
}
diags := bundle.Apply(context.Background(), b, mutator.InitializeVariables())
require.Empty(t, diags)

assert.NotNil(t, b.Config.Variables["foo"])
assert.NotNil(t, b.Config.Variables["bar"])
assert.Equal(t, "This is a description", b.Config.Variables["bar"].Description)
Expand All @@ -39,6 +38,5 @@ func TestInitializeVariablesWithoutVariables(t *testing.T) {
}
diags := bundle.Apply(context.Background(), b, mutator.InitializeVariables())
require.Empty(t, diags)

assert.Nil(t, b.Config.Variables)
}
2 changes: 1 addition & 1 deletion bundle/config/mutator/merge_job_clusters.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,6 @@ func (m *mergeJobClusters) Apply(ctx context.Context, b *bundle.Bundle) diag.Dia
return dyn.Map(job, "job_clusters", merge.ElementsByKey("job_cluster_key", m.jobClusterKey))
}))
})
return diag.FromErr(err)

return diag.FromErr(err)
}
1 change: 0 additions & 1 deletion bundle/config/mutator/merge_job_clusters_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,5 @@ func TestMergeJobClustersWithNilKey(t *testing.T) {

diags := bundle.Apply(context.Background(), b, mutator.MergeJobClusters())
assert.Empty(t, diags)

assert.Len(t, b.Config.Resources.Jobs["foo"].JobClusters, 1)
}
2 changes: 1 addition & 1 deletion bundle/config/mutator/merge_job_tasks.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,6 @@ func (m *mergeJobTasks) Apply(ctx context.Context, b *bundle.Bundle) diag.Diagno
return dyn.Map(job, "tasks", merge.ElementsByKey("task_key", m.taskKeyString))
}))
})
return diag.FromErr(err)

return diag.FromErr(err)
}
1 change: 0 additions & 1 deletion bundle/config/mutator/merge_job_tasks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,5 @@ func TestMergeJobTasksWithNilKey(t *testing.T) {

diags := bundle.Apply(context.Background(), b, mutator.MergeJobTasks())
assert.Empty(t, diags)

assert.Len(t, b.Config.Resources.Jobs["foo"].Tasks, 1)
}
2 changes: 1 addition & 1 deletion bundle/config/mutator/merge_pipeline_clusters.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,6 @@ func (m *mergePipelineClusters) Apply(ctx context.Context, b *bundle.Bundle) dia
return dyn.Map(pipeline, "clusters", merge.ElementsByKey("label", m.clusterLabel))
}))
})
return diag.FromErr(err)

return diag.FromErr(err)
}
2 changes: 0 additions & 2 deletions bundle/config/mutator/merge_pipeline_clusters_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ func TestMergePipelineClustersNilPipelines(t *testing.T) {

diags := bundle.Apply(context.Background(), b, mutator.MergePipelineClusters())
assert.Empty(t, diags)

}

func TestMergePipelineClustersEmptyPipelines(t *testing.T) {
Expand All @@ -123,5 +122,4 @@ func TestMergePipelineClustersEmptyPipelines(t *testing.T) {

diags := bundle.Apply(context.Background(), b, mutator.MergePipelineClusters())
assert.Empty(t, diags)

}
4 changes: 0 additions & 4 deletions bundle/config/mutator/override_compute_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ func TestOverrideDevelopment(t *testing.T) {
m := mutator.OverrideCompute()
diags := bundle.Apply(context.Background(), b, m)
require.Empty(t, diags)

assert.Nil(t, b.Config.Resources.Jobs["job1"].Tasks[0].NewCluster)
assert.Equal(t, "newClusterID", b.Config.Resources.Jobs["job1"].Tasks[0].ExistingClusterId)
assert.Equal(t, "newClusterID", b.Config.Resources.Jobs["job1"].Tasks[1].ExistingClusterId)
Expand Down Expand Up @@ -88,7 +87,6 @@ func TestOverrideDevelopmentEnv(t *testing.T) {
m := mutator.OverrideCompute()
diags := bundle.Apply(context.Background(), b, m)
require.Empty(t, diags)

assert.Equal(t, "cluster2", b.Config.Resources.Jobs["job1"].Tasks[1].ExistingClusterId)
}

Expand All @@ -114,7 +112,6 @@ func TestOverridePipelineTask(t *testing.T) {
m := mutator.OverrideCompute()
diags := bundle.Apply(context.Background(), b, m)
require.Empty(t, diags)

assert.Empty(t, b.Config.Resources.Jobs["job1"].Tasks[0].ExistingClusterId)
}

Expand Down Expand Up @@ -172,5 +169,4 @@ func TestOverrideProductionEnv(t *testing.T) {
m := mutator.OverrideCompute()
diags := bundle.Apply(context.Background(), b, m)
require.Empty(t, diags)

}
6 changes: 0 additions & 6 deletions bundle/config/mutator/process_root_includes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ func TestProcessRootIncludesEmpty(t *testing.T) {
}
diags := bundle.Apply(context.Background(), b, mutator.ProcessRootIncludes())
require.Empty(t, diags)

}

func TestProcessRootIncludesAbs(t *testing.T) {
Expand Down Expand Up @@ -65,7 +64,6 @@ func TestProcessRootIncludesSingleGlob(t *testing.T) {

diags := bundle.Apply(context.Background(), b, mutator.ProcessRootIncludes())
require.Empty(t, diags)

assert.Equal(t, []string{"a.yml", "b.yml"}, b.Config.Include)
}

Expand All @@ -85,7 +83,6 @@ func TestProcessRootIncludesMultiGlob(t *testing.T) {

diags := bundle.Apply(context.Background(), b, mutator.ProcessRootIncludes())
require.Empty(t, diags)

assert.Equal(t, []string{"a1.yml", "b1.yml"}, b.Config.Include)
}

Expand All @@ -104,7 +101,6 @@ func TestProcessRootIncludesRemoveDups(t *testing.T) {

diags := bundle.Apply(context.Background(), b, mutator.ProcessRootIncludes())
require.Empty(t, diags)

assert.Equal(t, []string{"a.yml"}, b.Config.Include)
}

Expand Down Expand Up @@ -136,7 +132,6 @@ func TestProcessRootIncludesExtrasFromEnvVar(t *testing.T) {

diags := bundle.Apply(context.Background(), b, mutator.ProcessRootIncludes())
require.Empty(t, diags)

assert.Contains(t, b.Config.Include, testYamlName)
}

Expand All @@ -160,6 +155,5 @@ func TestProcessRootIncludesDedupExtrasFromEnvVar(t *testing.T) {

diags := bundle.Apply(context.Background(), b, mutator.ProcessRootIncludes())
require.Empty(t, diags)

assert.Equal(t, []string{testYamlName}, b.Config.Include)
}
1 change: 0 additions & 1 deletion bundle/config/mutator/process_target_mode_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,6 @@ func TestProcessTargetModeDefault(t *testing.T) {
m := ProcessTargetMode()
diags := bundle.Apply(context.Background(), b, m)
require.Empty(t, diags)

assert.Equal(t, "job1", b.Config.Resources.Jobs["job1"].Name)
assert.Equal(t, "pipeline1", b.Config.Resources.Pipelines["pipeline1"].Name)
assert.False(t, b.Config.Resources.Pipelines["pipeline1"].PipelineSpec.Development)
Expand Down
3 changes: 0 additions & 3 deletions bundle/config/mutator/resolve_resource_references_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ func TestResolveClusterReference(t *testing.T) {

diags := bundle.Apply(context.Background(), b, ResolveResourceReferences())
require.Empty(t, diags)

require.Equal(t, "1234-5678-abcd", *b.Config.Variables["my-cluster-id-1"].Value)
require.Equal(t, "9876-5432-xywz", *b.Config.Variables["my-cluster-id-2"].Value)
}
Expand Down Expand Up @@ -105,7 +104,6 @@ func TestNoLookupIfVariableIsSet(t *testing.T) {

diags := bundle.Apply(context.Background(), b, ResolveResourceReferences())
require.Empty(t, diags)

require.Equal(t, "random value", *b.Config.Variables["my-cluster-id"].Value)
}

Expand Down Expand Up @@ -133,6 +131,5 @@ func TestResolveServicePrincipal(t *testing.T) {

diags := bundle.Apply(context.Background(), b, ResolveResourceReferences())
require.Empty(t, diags)

require.Equal(t, "app-1234", *b.Config.Variables["my-sp"].Value)
}
2 changes: 1 addition & 1 deletion bundle/config/mutator/resolve_variable_references.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,6 @@ func (m *resolveVariableReferences) Apply(ctx context.Context, b *bundle.Bundle)
}
return root, nil
})
return diag.FromErr(err)

return diag.FromErr(err)
}
2 changes: 1 addition & 1 deletion bundle/config/mutator/rewrite_sync_paths.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,6 @@ func (m *rewriteSyncPaths) Apply(ctx context.Context, b *bundle.Bundle) diag.Dia
return v, nil
})
})
return diag.FromErr(err)

return diag.FromErr(err)
}
2 changes: 0 additions & 2 deletions bundle/config/mutator/rewrite_sync_paths_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ func TestRewriteSyncPathsErrorPaths(t *testing.T) {

diags := bundle.Apply(context.Background(), b, mutator.RewriteSyncPaths())
assert.Empty(t, diags)

})

t.Run("empty include/exclude blocks", func(t *testing.T) {
Expand All @@ -100,6 +99,5 @@ func TestRewriteSyncPathsErrorPaths(t *testing.T) {

diags := bundle.Apply(context.Background(), b, mutator.RewriteSyncPaths())
assert.Empty(t, diags)

})
}
6 changes: 0 additions & 6 deletions bundle/config/mutator/select_default_target_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ func TestSelectDefaultTargetNoTargets(t *testing.T) {
}
diags := bundle.Apply(context.Background(), b, mutator.SelectDefaultTarget())
assert.ErrorContains(t, diags.Error(), "no targets defined")

}

func TestSelectDefaultTargetSingleTargets(t *testing.T) {
Expand All @@ -31,7 +30,6 @@ func TestSelectDefaultTargetSingleTargets(t *testing.T) {
}
diags := bundle.Apply(context.Background(), b, mutator.SelectDefaultTarget())
assert.Empty(t, diags)

assert.Equal(t, "foo", b.Config.Bundle.Target)
}

Expand All @@ -47,7 +45,6 @@ func TestSelectDefaultTargetNoDefaults(t *testing.T) {
}
diags := bundle.Apply(context.Background(), b, mutator.SelectDefaultTarget())
assert.ErrorContains(t, diags.Error(), "please specify target")

}

func TestSelectDefaultTargetNoDefaultsWithNil(t *testing.T) {
Expand All @@ -61,7 +58,6 @@ func TestSelectDefaultTargetNoDefaultsWithNil(t *testing.T) {
}
diags := bundle.Apply(context.Background(), b, mutator.SelectDefaultTarget())
assert.ErrorContains(t, diags.Error(), "please specify target")

}

func TestSelectDefaultTargetMultipleDefaults(t *testing.T) {
Expand All @@ -76,7 +72,6 @@ func TestSelectDefaultTargetMultipleDefaults(t *testing.T) {
}
diags := bundle.Apply(context.Background(), b, mutator.SelectDefaultTarget())
assert.ErrorContains(t, diags.Error(), "multiple targets are marked as default")

}

func TestSelectDefaultTargetSingleDefault(t *testing.T) {
Expand All @@ -91,6 +86,5 @@ func TestSelectDefaultTargetSingleDefault(t *testing.T) {
}
diags := bundle.Apply(context.Background(), b, mutator.SelectDefaultTarget())
assert.Empty(t, diags)

assert.Equal(t, "bar", b.Config.Bundle.Target)
}
2 changes: 0 additions & 2 deletions bundle/config/mutator/select_target_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ func TestSelectTarget(t *testing.T) {
}
diags := bundle.Apply(context.Background(), b, mutator.SelectTarget("default"))
require.Empty(t, diags)

assert.Equal(t, "bar", b.Config.Workspace.Host)
}

Expand All @@ -42,5 +41,4 @@ func TestSelectTargetNotFound(t *testing.T) {
}
diags := bundle.Apply(context.Background(), b, mutator.SelectTarget("doesnt-exist"))
require.Error(t, diags.Error(), "no targets defined")

}
1 change: 0 additions & 1 deletion bundle/config/mutator/set_variables_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ func TestSetVariablesMutator(t *testing.T) {

diags := bundle.Apply(context.Background(), b, SetVariables())
require.Empty(t, diags)

assert.Equal(t, "default-a", *b.Config.Variables["a"].Value)
assert.Equal(t, "env-var-b", *b.Config.Variables["b"].Value)
assert.Equal(t, "assigned-val-c", *b.Config.Variables["c"].Value)
Expand Down
1 change: 1 addition & 0 deletions bundle/config/mutator/translate_paths.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,5 +203,6 @@ func (m *translatePaths) Apply(_ context.Context, b *bundle.Bundle) diag.Diagnos
}
return v, nil
})

return diag.FromErr(err)
}
5 changes: 0 additions & 5 deletions bundle/config/mutator/translate_paths_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,6 @@ func TestTranslatePathsOutsideBundleRoot(t *testing.T) {

diags := bundle.Apply(context.Background(), b, mutator.TranslatePaths())
assert.ErrorContains(t, diags.Error(), "is not contained in bundle root")

}

func TestJobNotebookDoesNotExistError(t *testing.T) {
Expand Down Expand Up @@ -549,7 +548,6 @@ func TestJobSparkPythonTaskWithNotebookSourceError(t *testing.T) {

diags := bundle.Apply(context.Background(), b, mutator.TranslatePaths())
assert.ErrorContains(t, diags.Error(), `expected a file for "resources.jobs.job.tasks[0].spark_python_task.python_file" but got a notebook`)

}

func TestJobNotebookTaskWithFileSourceError(t *testing.T) {
Expand Down Expand Up @@ -584,7 +582,6 @@ func TestJobNotebookTaskWithFileSourceError(t *testing.T) {

diags := bundle.Apply(context.Background(), b, mutator.TranslatePaths())
assert.ErrorContains(t, diags.Error(), `expected a notebook for "resources.jobs.job.tasks[0].notebook_task.notebook_path" but got a file`)

}

func TestPipelineNotebookLibraryWithFileSourceError(t *testing.T) {
Expand Down Expand Up @@ -619,7 +616,6 @@ func TestPipelineNotebookLibraryWithFileSourceError(t *testing.T) {

diags := bundle.Apply(context.Background(), b, mutator.TranslatePaths())
assert.ErrorContains(t, diags.Error(), `expected a notebook for "resources.pipelines.pipeline.libraries[0].notebook.path" but got a file`)

}

func TestPipelineFileLibraryWithNotebookSourceError(t *testing.T) {
Expand Down Expand Up @@ -654,5 +650,4 @@ func TestPipelineFileLibraryWithNotebookSourceError(t *testing.T) {

diags := bundle.Apply(context.Background(), b, mutator.TranslatePaths())
assert.ErrorContains(t, diags.Error(), `expected a file for "resources.pipelines.pipeline.libraries[0].file.path" but got a notebook`)

}
9 changes: 2 additions & 7 deletions bundle/config/mutator/validate_git_details_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ func TestValidateGitDetailsMatchingBranches(t *testing.T) {
m := ValidateGitDetails()
diags := bundle.Apply(context.Background(), b, m)
assert.Empty(t, diags)

}

func TestValidateGitDetailsNonMatchingBranches(t *testing.T) {
Expand All @@ -42,11 +41,8 @@ func TestValidateGitDetailsNonMatchingBranches(t *testing.T) {
m := ValidateGitDetails()
diags := bundle.Apply(context.Background(), b, m)

// expectedError := "not on the right Git branch:\n expected according to configuration: main\n actual: feature\nuse --force to override"
assert.EqualError(t, diags.Error(), `not on the right Git branch:
expected according to configuration: main
actual: feature
use --force to override`)
expectedError := "not on the right Git branch:\n expected according to configuration: main\n actual: feature\nuse --force to override"
assert.EqualError(t, diags.Error(), expectedError)
}

func TestValidateGitDetailsNotUsingGit(t *testing.T) {
Expand All @@ -64,5 +60,4 @@ func TestValidateGitDetailsNotUsingGit(t *testing.T) {
m := ValidateGitDetails()
diags := bundle.Apply(context.Background(), b, m)
assert.Empty(t, diags)

}
1 change: 1 addition & 0 deletions bundle/deploy/terraform/load_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,6 @@ func TestLoadWithNoState(t *testing.T) {
Initialize(),
Load(ErrorOnEmptyState),
))

require.ErrorContains(t, diags.Error(), "Did you forget to run 'databricks bundle deploy'")
}
1 change: 0 additions & 1 deletion bundle/deploy/terraform/state_push_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,4 @@ func TestStatePush(t *testing.T) {
writeLocalState(t, ctx, b, map[string]int{"serial": 4})
diags := bundle.Apply(ctx, b, m)
assert.Empty(t, diags)

}
1 change: 1 addition & 0 deletions bundle/log_string.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@ func LogString(message string) Mutator {

func (m *LogStringMutator) Apply(ctx context.Context, b *Bundle) diag.Diagnostics {
cmdio.LogString(ctx, m.message)

return nil
}
2 changes: 1 addition & 1 deletion bundle/permissions/filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,6 @@ func (m *filterCurrentUser) Apply(ctx context.Context, b *bundle.Bundle) diag.Di
// Set the resources with the filtered permissions back into the bundle
return dyn.Set(v, "resources", nv)
})
return diag.FromErr(err)

return diag.FromErr(err)
}
1 change: 0 additions & 1 deletion bundle/permissions/filter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,5 +171,4 @@ func TestFilterCurrentUserDoesNotErrorWhenNoResources(t *testing.T) {

diags := bundle.Apply(context.Background(), b, FilterCurrentUser())
assert.Empty(t, diags)

}
1 change: 0 additions & 1 deletion bundle/permissions/workspace_root_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,5 +71,4 @@ func TestApplyWorkspaceRootPermissions(t *testing.T) {

diags := bundle.Apply(context.Background(), b, ApplyWorkspaceRootPermissions())
require.Empty(t, diags)

}
Loading

0 comments on commit fa7c64e

Please sign in to comment.