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.
This commit is contained in:
Lennart Kats (databricks) 2024-12-27 12:38:12 +01:00 committed by GitHub
parent 793bf2b995
commit a002475a6a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 15 additions and 9 deletions

View File

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