Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

atlasaction: move template test to testscript #282

Merged
merged 1 commit into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,6 @@ lib/**/*

# IDE files
.idea/

# the binary file for the atlas-action
atlas-action
8 changes: 4 additions & 4 deletions atlasaction/action.go
Original file line number Diff line number Diff line change
Expand Up @@ -1087,9 +1087,9 @@ func appliedStmts(a *atlasexec.MigrateApply) int {
}

var (
//go:embed comments/*.tmpl
//go:embed comments
comments embed.FS
commentsTmpl = template.Must(
CommentsTmpl = template.Must(
template.New("comments").
Funcs(template.FuncMap{
"execTime": execTime,
Expand Down Expand Up @@ -1155,14 +1155,14 @@ var (
return fmt.Sprintf(`<picture><source media="(prefers-color-scheme: light)" srcset=%q><img %s/></picture>`, src, attrs), nil
},
}).
ParseFS(comments, "comments/*.tmpl"),
ParseFS(comments, "comments/*"),
)
)

// RenderTemplate renders the given template with the data.
func RenderTemplate(name string, data any) (string, error) {
var buf bytes.Buffer
if err := commentsTmpl.ExecuteTemplate(&buf, name, data); err != nil {
if err := CommentsTmpl.ExecuteTemplate(&buf, name, data); err != nil {
return "", err
}
return buf.String(), nil
Expand Down
Loading
Loading