-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Report all empty resources present in error diagnostic (#1685)
## Changes This PR addressed post-merge feedback from #1673. ## Tests Unit tests, and manually. ``` Error: experiment undefined-experiment is not defined at resources.experiments.undefined-experiment in databricks.yml:11:26 Error: job undefined-job is not defined at resources.jobs.undefined-job in databricks.yml:6:19 Error: pipeline undefined-pipeline is not defined at resources.pipelines.undefined-pipeline in databricks.yml:14:24 Name: undefined-job Target: default Found 3 errors ```
- Loading branch information
1 parent
78d0ac5
commit 242d4b5
Showing
7 changed files
with
90 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
bundle: | ||
name: undefined-job | ||
|
||
resources: | ||
jobs: | ||
undefined-job: | ||
test: | ||
name: "Test Job" | ||
|
||
experiments: | ||
undefined-experiment: | ||
|
||
pipelines: | ||
undefined-pipeline: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package config_tests | ||
|
||
import ( | ||
"context" | ||
"path/filepath" | ||
"testing" | ||
|
||
"github.com/databricks/cli/bundle" | ||
"github.com/databricks/cli/bundle/config/validate" | ||
"github.com/databricks/cli/libs/diag" | ||
"github.com/databricks/cli/libs/dyn" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestUndefinedResourcesLoadWithError(t *testing.T) { | ||
b := load(t, "./undefined_resources") | ||
diags := bundle.Apply(context.Background(), b, validate.AllResourcesHaveValues()) | ||
|
||
assert.Len(t, diags, 3) | ||
assert.Contains(t, diags, diag.Diagnostic{ | ||
Severity: diag.Error, | ||
Summary: "job undefined-job is not defined", | ||
Locations: []dyn.Location{{ | ||
File: filepath.FromSlash("undefined_resources/databricks.yml"), | ||
Line: 6, | ||
Column: 19, | ||
}}, | ||
Paths: []dyn.Path{dyn.MustPathFromString("resources.jobs.undefined-job")}, | ||
}) | ||
assert.Contains(t, diags, diag.Diagnostic{ | ||
Severity: diag.Error, | ||
Summary: "experiment undefined-experiment is not defined", | ||
Locations: []dyn.Location{{ | ||
File: filepath.FromSlash("undefined_resources/databricks.yml"), | ||
Line: 11, | ||
Column: 26, | ||
}}, | ||
Paths: []dyn.Path{dyn.MustPathFromString("resources.experiments.undefined-experiment")}, | ||
}) | ||
assert.Contains(t, diags, diag.Diagnostic{ | ||
Severity: diag.Error, | ||
Summary: "pipeline undefined-pipeline is not defined", | ||
Locations: []dyn.Location{{ | ||
File: filepath.FromSlash("undefined_resources/databricks.yml"), | ||
Line: 14, | ||
Column: 24, | ||
}}, | ||
Paths: []dyn.Path{dyn.MustPathFromString("resources.pipelines.undefined-pipeline")}, | ||
}) | ||
} |