Skip to content

Commit

Permalink
atlasaction: move template test to testscript (#282)
Browse files Browse the repository at this point in the history
  • Loading branch information
giautm authored Dec 18, 2024
1 parent a54a483 commit 3a718d2
Show file tree
Hide file tree
Showing 5 changed files with 357 additions and 403 deletions.
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

0 comments on commit 3a718d2

Please sign in to comment.