fix template test renderer, add category
This commit is contained in:
parent
d9146750ba
commit
e4317ec4fd
15 changed files with 171 additions and 103 deletions
|
@ -2,14 +2,20 @@ package utils
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"git.sapphic.engineer/roleypoly/v4/types"
|
||||
"html/template"
|
||||
)
|
||||
|
||||
func RoleInputID(c *types.Category, r *types.Role) string {
|
||||
return fmt.Sprintf("category-%s_role-%s", c.ID, r.ID)
|
||||
func RoleInputID(c string, r string) string {
|
||||
return fmt.Sprintf("category-%s_role-%s", c, r)
|
||||
}
|
||||
|
||||
func RoleInputName(c *types.Category) string {
|
||||
return fmt.Sprintf("category_group_%s", c.ID)
|
||||
func RoleInputName(c string) string {
|
||||
return fmt.Sprintf("category_group_%s", c)
|
||||
}
|
||||
|
||||
func TemplateFuncs() template.FuncMap {
|
||||
return template.FuncMap{
|
||||
"roleInputID": RoleInputID,
|
||||
"roleInputName": RoleInputName,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,15 +3,14 @@ package utils_test
|
|||
import (
|
||||
"testing"
|
||||
|
||||
"git.sapphic.engineer/roleypoly/v4/types"
|
||||
"git.sapphic.engineer/roleypoly/v4/utils"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestRoleInputID(t *testing.T) {
|
||||
assert.Equal(t, "category-123_role-456", utils.RoleInputID(&types.Category{ID: "123"}, &types.Role{ID: "456"}))
|
||||
assert.Equal(t, "category-123_role-456", utils.RoleInputID("123", "456"))
|
||||
}
|
||||
|
||||
func TestRoleInputName(t *testing.T) {
|
||||
assert.Equal(t, "category_group_123", utils.RoleInputName(&types.Category{ID: "123"}))
|
||||
assert.Equal(t, "category_group_123", utils.RoleInputName("123"))
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue