Compare commits

...

3 Commits

Author SHA1 Message Date
Shreyas Goenka e44eebc58f
fix broken integration test 2024-12-30 20:59:46 +05:30
Shreyas Goenka a8a12483ad
Merge remote-tracking branch 'origin' into add-bundle-init-event 2024-12-30 16:01:59 +05:30
Lennart Kats (databricks) a002475a6a
Relax checks in builtin template tests (#2042)
## Changes
Relax the checks of `lib/template/builtin_test` so they don't fail for a
local development copy that has uncommitted draft templates. Right now
these tests fail because I have some git-ignored uncommitted templates
in my local dev copy.
2024-12-27 11:38:12 +00:00
2 changed files with 16 additions and 10 deletions

View File

@ -246,7 +246,7 @@ func TestBundleInitTelemetryForCustomTemplates(t *testing.T) {
require.Equal(t, 1, len(logs))
event := logs[0].Entry.DatabricksCliLog.BundleInitEvent
assert.Equal(t, event.TemplateName, "custom")
assert.Nil(t, event.TemplateEnumArgs)
assert.Empty(t, event.TemplateEnumArgs)
// Ensure that the UUID returned by the `bundle_uuid` helper is the same UUID
// that's logged in the telemetry event.

View File

@ -11,18 +11,24 @@ import (
func TestBuiltin(t *testing.T) {
out, err := Builtin()
require.NoError(t, err)
assert.Len(t, out, 3)
assert.GreaterOrEqual(t, len(out), 3)
// Confirm names.
assert.Equal(t, "dbt-sql", out[0].Name)
assert.Equal(t, "default-python", out[1].Name)
assert.Equal(t, "default-sql", out[2].Name)
// Create a map of templates by name for easier lookup
templates := make(map[string]*BuiltinTemplate)
for _, tmpl := range out {
templates[tmpl.Name] = &tmpl
}
// Confirm that the filesystems work.
_, err = fs.Stat(out[0].FS, `template/{{.project_name}}/dbt_project.yml.tmpl`)
// Verify all expected templates exist
assert.Contains(t, templates, "dbt-sql")
assert.Contains(t, templates, "default-python")
assert.Contains(t, templates, "default-sql")
// Verify the filesystems work for each template
_, err = fs.Stat(templates["dbt-sql"].FS, `template/{{.project_name}}/dbt_project.yml.tmpl`)
assert.NoError(t, err)
_, err = fs.Stat(out[1].FS, `template/{{.project_name}}/tests/main_test.py.tmpl`)
_, err = fs.Stat(templates["default-python"].FS, `template/{{.project_name}}/tests/main_test.py.tmpl`)
assert.NoError(t, err)
_, err = fs.Stat(out[2].FS, `template/{{.project_name}}/src/orders_daily.sql.tmpl`)
_, err = fs.Stat(templates["default-sql"].FS, `template/{{.project_name}}/src/orders_daily.sql.tmpl`)
assert.NoError(t, err)
}