gh-ost/go/logic/progress_test.go

47 lines
945 B
Go
Raw Permalink Normal View History

2016-09-12 17:05:57 +00:00
/*
Copyright 2016 GitHub Inc.
See https://github.com/github/gh-ost/blob/master/LICENSE
*/
package logic
import (
"testing"
"time"
"github.com/outbrain/golib/log"
test "github.com/outbrain/golib/tests"
)
func init() {
log.SetLevel(log.ERROR)
}
func TestNewProgressHistory(t *testing.T) {
progressHistory := NewProgressHistory()
2016-10-24 11:37:19 +00:00
test.S(t).ExpectTrue(progressHistory.lastProgressState == nil)
2016-09-12 17:05:57 +00:00
}
func TestMarkState(t *testing.T) {
{
progressHistory := NewProgressHistory()
2016-10-24 11:37:19 +00:00
_, err := progressHistory.markState(0, 0)
test.S(t).ExpectNotNil(err)
2016-09-12 17:05:57 +00:00
}
{
progressHistory := NewProgressHistory()
2016-10-24 11:37:19 +00:00
_, err := progressHistory.markState(0, 0.01)
test.S(t).ExpectNotNil(err)
2016-09-12 17:05:57 +00:00
}
{
progressHistory := NewProgressHistory()
2016-10-24 11:37:19 +00:00
_, err := progressHistory.markState(0, 50)
test.S(t).ExpectNotNil(err)
2016-09-12 17:05:57 +00:00
}
{
progressHistory := NewProgressHistory()
2016-10-24 11:37:19 +00:00
_, err := progressHistory.markState(time.Hour, 50)
test.S(t).ExpectNil(err)
2016-09-12 17:05:57 +00:00
}
}