2024-11-20 09:28:35 +00:00
|
|
|
package template
|
|
|
|
|
|
|
|
import (
|
|
|
|
"io/fs"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestBuiltin(t *testing.T) {
|
|
|
|
out, err := Builtin()
|
|
|
|
require.NoError(t, err)
|
2024-12-27 11:38:12 +00:00
|
|
|
assert.GreaterOrEqual(t, len(out), 3)
|
2024-11-20 09:28:35 +00:00
|
|
|
|
2024-12-27 11:38:12 +00:00
|
|
|
// Create a map of templates by name for easier lookup
|
|
|
|
templates := make(map[string]*BuiltinTemplate)
|
|
|
|
for _, tmpl := range out {
|
|
|
|
templates[tmpl.Name] = &tmpl
|
|
|
|
}
|
2024-11-20 09:28:35 +00:00
|
|
|
|
2024-12-27 11:38:12 +00:00
|
|
|
// 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`)
|
2024-11-20 09:28:35 +00:00
|
|
|
assert.NoError(t, err)
|
2024-12-27 11:38:12 +00:00
|
|
|
_, err = fs.Stat(templates["default-python"].FS, `template/{{.project_name}}/tests/main_test.py.tmpl`)
|
2024-11-20 09:28:35 +00:00
|
|
|
assert.NoError(t, err)
|
2024-12-27 11:38:12 +00:00
|
|
|
_, err = fs.Stat(templates["default-sql"].FS, `template/{{.project_name}}/src/orders_daily.sql.tmpl`)
|
2024-11-20 09:28:35 +00:00
|
|
|
assert.NoError(t, err)
|
|
|
|
}
|