Beispiel #1
0
func toggleTrackActivation(ctx *_Context) error {

	track, err := table.FindTrack(ctx.urlParams["track_id"].(int64))
	if err != nil {
		return err
	}

	now := time.Now()

	if track.Active(now) {
		err = table.DeactivateTrack(track.TrackId, now)
	} else {
		err = table.ActivateTrack(track.TrackId, now)
	}

	return err
}
Beispiel #2
0
func TestDeactivateActivate(t *T) {
	beforeTrackTest()

	now := time.Date(1986, 7, 2, 0, 0, 0, 0, time.UTC)

	err := table.DeactivateTrack(3, now)
	rdtest.Assert(t, err == nil, err)

	found, err := table.FindTrack(3)
	rdtest.Assert(t, err == nil, err)
	rdtest.Assert(t, !found.Active(now))

	err = table.ActivateTrack(3, now)
	rdtest.Assert(t, err == nil, err)

	found, err = table.FindTrack(3)
	rdtest.Assert(t, err == nil, err)
	rdtest.Assert(t, found.Active(now))
}