diff --git a/radio.go b/radio.go index c1d48f0..7d6723b 100644 --- a/radio.go +++ b/radio.go @@ -1259,7 +1259,7 @@ const ( Friday Saturday Sunday - UnknownDay = 255 + UnknownDay ScheduleDay = 255 ) func ParseScheduleDay(s string) ScheduleDay { diff --git a/util/util.go b/util/util.go index 1584ce2..20f433a 100644 --- a/util/util.go +++ b/util/util.go @@ -230,22 +230,22 @@ func (v *Value[T]) Latest() T { return *v.last.Load() } -type TimerCallback struct { +type CallbackTimer struct { fn func() mu sync.Mutex timer *time.Timer } -func NewCallbackTimer(callback func()) *TimerCallback { - return &TimerCallback{ +func NewCallbackTimer(callback func()) *CallbackTimer { + return &CallbackTimer{ fn: callback, } } // Start starts a timer with the timeout given, if a timer // is already running it is stopped and a new timer is created -func (tc *TimerCallback) Start(timeout time.Duration) { +func (tc *CallbackTimer) Start(timeout time.Duration) { tc.mu.Lock() defer tc.mu.Unlock() if tc.timer != nil { @@ -255,7 +255,7 @@ func (tc *TimerCallback) Start(timeout time.Duration) { } // Stop stops the current timer if one exists -func (tc *TimerCallback) Stop() bool { +func (tc *CallbackTimer) Stop() bool { tc.mu.Lock() defer tc.mu.Unlock() if tc.timer != nil { diff --git a/website/admin/schedule_test.go b/website/admin/schedule_test.go index 8b73719..ae28a25 100644 --- a/website/admin/schedule_test.go +++ b/website/admin/schedule_test.go @@ -40,6 +40,14 @@ func TestScheduleForm(t *testing.T) { assert.Equal(t, getByDJIDRet.DJ.ID, dJID) return getByDJIDRet, nil }, + AllFunc: func() ([]radio.User, error) { + if getByDJIDRet == nil { + return []radio.User{}, nil + } + return []radio.User{ + *getByDJIDRet, + }, nil + }, } p.Property("schedule form should roundtrip", prop.ForAll(