From a002475a6a4175cb0fa4ef09e21ef8bcecd84899 Mon Sep 17 00:00:00 2001 From: "Lennart Kats (databricks)" Date: Fri, 27 Dec 2024 12:38:12 +0100 Subject: [PATCH] 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. --- libs/template/builtin_test.go | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/libs/template/builtin_test.go b/libs/template/builtin_test.go index 504e0acca..79e04cb84 100644 --- a/libs/template/builtin_test.go +++ b/libs/template/builtin_test.go @@ -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) }