catbase/plugins/goals/goals_test.go

76 lines
1.1 KiB
Go
Raw Normal View History

2020-07-13 15:34:53 +00:00
package goals
import (
"testing"
"time"
"github.com/stretchr/testify/assert"
"github.com/velour/catbase/bot"
"github.com/velour/catbase/plugins/counter"
)
func TestRemainingSomeToGo(t *testing.T) {
mb := bot.NewMockBot()
i := counter.Item{
DB: mb.DB(),
ID: 0,
Nick: "",
Item: "",
Count: 190,
}
g := goal{
ID: 0,
Kind: "",
Who: "",
What: "",
Amount: 366,
gp: nil,
}
now = func() time.Time {
return time.Date(2020, 07, 13, 11, 23, 00, 00, time.UTC)
}
p := New(mb)
expected := 5
actual := p.calculateRemaining(i, &g)
assert.Equal(t, expected, actual)
}
func TestRemainingAheadOfCurve(t *testing.T) {
mb := bot.NewMockBot()
i := counter.Item{
DB: mb.DB(),
ID: 0,
Nick: "",
Item: "",
Count: 200,
}
g := goal{
ID: 0,
Kind: "",
Who: "",
What: "",
Amount: 366,
gp: nil,
}
now = func() time.Time {
return time.Date(2020, 07, 13, 11, 23, 00, 00, time.UTC)
}
p := New(mb)
expected := -5
actual := p.calculateRemaining(i, &g)
assert.Equal(t, expected, actual)
}