Fix/#1035 parse templates for icon (#1055)
This commit is contained in:
commit
6ac63be916
|
|
@ -1019,7 +1019,7 @@ func stepRequestActionPopulateLogEntry(req *ExecutionRequest) {
|
|||
entry.Binding = req.Binding
|
||||
entry.ActionConfigTitle = req.Binding.Action.Title
|
||||
entry.ActionTitle = tpl.ParseTemplateOfActionBeforeExec(req.Binding.Action.Title, req.Binding.Entity)
|
||||
entry.ActionIcon = req.Binding.Action.Icon
|
||||
entry.ActionIcon = tpl.ParseTemplateOfActionBeforeExec(req.Binding.Action.Icon, req.Binding.Entity)
|
||||
entry.Tags = req.Tags
|
||||
entry.Justification = ResolveJustification(req)
|
||||
if req.Binding.Entity != nil {
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import (
|
|||
"github.com/OliveTin/OliveTin/internal/auth"
|
||||
authpublic "github.com/OliveTin/OliveTin/internal/auth/authpublic"
|
||||
config "github.com/OliveTin/OliveTin/internal/config"
|
||||
"github.com/OliveTin/OliveTin/internal/entities"
|
||||
)
|
||||
|
||||
func testingExecutor() (*Executor, *config.Config) {
|
||||
|
|
@ -59,6 +60,32 @@ func TestCreateExecutorAndExec(t *testing.T) {
|
|||
assert.Equal(t, int32(0), req.logEntry.ExitCode, "Exit code is zero")
|
||||
}
|
||||
|
||||
func TestStepRequestActionPopulateLogEntryResolvesEntityTemplates(t *testing.T) {
|
||||
req := &ExecutionRequest{
|
||||
logEntry: &InternalLogEntry{},
|
||||
Binding: &ActionBinding{
|
||||
Action: &config.Action{
|
||||
Title: "Do something with {{ project.name }}",
|
||||
Icon: "{{ project.icon }}",
|
||||
},
|
||||
Entity: &entities.Entity{
|
||||
Data: map[string]any{
|
||||
"name": "foo",
|
||||
"icon": "🐰",
|
||||
},
|
||||
UniqueKey: "foo-key",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
stepRequestActionPopulateLogEntry(req)
|
||||
|
||||
assert.Equal(t, "Do something with foo", req.logEntry.ActionTitle)
|
||||
assert.Equal(t, "🐰", req.logEntry.ActionIcon)
|
||||
assert.Equal(t, "Do something with {{ project.name }}", req.logEntry.ActionConfigTitle)
|
||||
assert.Equal(t, "foo-key", req.logEntry.EntityPrefix)
|
||||
}
|
||||
|
||||
func TestExecNonExistant(t *testing.T) {
|
||||
e, cfg := testingExecutor()
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue