1
0
mirror of https://github.com/velour/catbase.git synced 2025-04-03 19:51:42 +00:00
catbase/plugins/last/last_test.go
2021-04-27 12:45:52 -04:00

28 lines
679 B
Go

package last
import (
"os"
"testing"
"time"
"github.com/rs/zerolog"
"github.com/rs/zerolog/log"
"github.com/stretchr/testify/assert"
)
func TestNextNoonBeforeNoon(t *testing.T) {
log.Logger = log.Logger.Output(zerolog.ConsoleWriter{Out: os.Stderr})
t0 := time.Date(2021, 04, 27, 10, 10, 0, 0, time.Local)
t1 := nextNoon(t0)
expected := 1*time.Hour + 50*time.Minute
assert.Equal(t, expected, t1)
}
func TestNextNoonAfterNoon(t *testing.T) {
log.Logger = log.Logger.Output(zerolog.ConsoleWriter{Out: os.Stderr})
t0 := time.Date(2021, 04, 27, 14, 15, 0, 0, time.Local)
t1 := nextNoon(t0)
expected := 21*time.Hour + 45*time.Minute
assert.Equal(t, expected, t1)
}