Skip to content

Commit

Permalink
fix (some) failing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Wessie committed May 13, 2024
1 parent 2ae539b commit b87fb8e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
2 changes: 1 addition & 1 deletion radio.go
Original file line number Diff line number Diff line change
Expand Up @@ -1259,7 +1259,7 @@ const (
Friday
Saturday
Sunday
UnknownDay = 255
UnknownDay ScheduleDay = 255
)

func ParseScheduleDay(s string) ScheduleDay {
Expand Down
10 changes: 5 additions & 5 deletions util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 {
Expand Down
8 changes: 8 additions & 0 deletions website/admin/schedule_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit b87fb8e

Please sign in to comment.