You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
437 B
Go
26 lines
437 B
Go
4 years ago
|
package timex
|
||
|
|
||
|
import (
|
||
|
"testing"
|
||
|
"time"
|
||
|
|
||
|
"github.com/stretchr/testify/assert"
|
||
|
)
|
||
|
|
||
|
func TestRelativeTime(t *testing.T) {
|
||
|
time.Sleep(time.Millisecond)
|
||
|
now := Now()
|
||
|
assert.True(t, now > 0)
|
||
|
time.Sleep(time.Millisecond)
|
||
|
assert.True(t, Since(now) > 0)
|
||
|
}
|
||
|
|
||
|
func TestRelativeTime_Time(t *testing.T) {
|
||
|
diff := Time().Sub(time.Now())
|
||
|
if diff > 0 {
|
||
|
assert.True(t, diff < time.Second)
|
||
|
} else {
|
||
|
assert.True(t, -diff < time.Second)
|
||
|
}
|
||
|
}
|