Adopt SummerCMS v0.1.1 admin features
Datepickers on native time.Time / lagoon.Date fields, file uploads on materials, readings and class sessions managed from the course form (course_id made nullable).
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"errors"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"git.golem15.com/golem15/summercms/modules/cabana"
|
||||
"git.golem15.com/jakub/sm-bm-plugin/models"
|
||||
@@ -11,7 +12,8 @@ import (
|
||||
|
||||
func TestTemporalHooksAnswerOnTheField(t *testing.T) {
|
||||
var hooks temporalHooks
|
||||
bad := &models.ClassSession{StartsAt: "2026-10-03 08:00", EndsAt: "wtorek"}
|
||||
at := func(h, m int) time.Time { return time.Date(2026, 10, 3, h, m, 0, 0, models.Location) }
|
||||
bad := &models.ClassSession{StartsAt: at(8, 0), EndsAt: at(7, 0)}
|
||||
for name, fn := range map[string]func(context.Context, any) error{
|
||||
"create": hooks.FormBeforeCreate,
|
||||
"update": hooks.FormBeforeUpdate,
|
||||
@@ -25,7 +27,7 @@ func TestTemporalHooksAnswerOnTheField(t *testing.T) {
|
||||
t.Errorf("%s: details %v name no ends_at", name, ve.Details)
|
||||
}
|
||||
}
|
||||
good := &models.ClassSession{StartsAt: "2026-10-03 08:00", EndsAt: "2026-10-03 09:30"}
|
||||
good := &models.ClassSession{StartsAt: at(8, 0), EndsAt: at(9, 30)}
|
||||
if err := hooks.FormBeforeCreate(context.Background(), good); err != nil {
|
||||
t.Errorf("valid session: %v", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user