-
Notifications
You must be signed in to change notification settings - Fork 29
Expand file tree
/
Copy pathinterval_test.go
More file actions
61 lines (43 loc) · 1005 Bytes
/
interval_test.go
File metadata and controls
61 lines (43 loc) · 1005 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package sqlutil
import (
"testing"
"time"
"github.com/stretchr/testify/require"
)
func TestNewInterval(t *testing.T) {
t.Parallel()
duration := 33 * time.Second
interval := NewInterval(duration)
require.Equal(t, duration, interval.Duration())
}
func TestInterval_IsZero(t *testing.T) {
t.Parallel()
i := NewInterval(0)
require.NotNil(t, i)
require.True(t, i.IsZero())
i = NewInterval(1)
require.NotNil(t, i)
require.False(t, i.IsZero())
}
func TestInterval_Scan_Value(t *testing.T) {
t.Parallel()
i := NewInterval(100)
require.NotNil(t, i)
val, err := i.Value()
require.NoError(t, err)
iNew := NewInterval(0)
err = iNew.Scan(val)
require.NoError(t, err)
require.Equal(t, i, iNew)
}
func TestInterval_MarshalText_UnmarshalText(t *testing.T) {
t.Parallel()
i := NewInterval(100)
require.NotNil(t, i)
txt, err := i.MarshalText()
require.NoError(t, err)
iNew := NewInterval(0)
err = iNew.UnmarshalText(txt)
require.NoError(t, err)
require.Equal(t, i, iNew)
}