forked from argoproj/argo-workflows
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ttl_test.go
32 lines (29 loc) · 631 Bytes
/
ttl_test.go
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
package config
import (
"testing"
"time"
"github.com/stretchr/testify/assert"
)
func TestTTL(t *testing.T) {
t.Run("Empty", func(t *testing.T) {
ttl := TTL(-1)
err := ttl.UnmarshalJSON([]byte(`""`))
if assert.NoError(t, err) {
assert.Equal(t, TTL(0), ttl)
}
})
t.Run("1h", func(t *testing.T) {
ttl := TTL(-1)
err := ttl.UnmarshalJSON([]byte(`"1h"`))
if assert.NoError(t, err) {
assert.Equal(t, TTL(1*time.Hour), ttl)
}
})
t.Run("1d", func(t *testing.T) {
ttl := TTL(-1)
err := ttl.UnmarshalJSON([]byte(`"1d"`))
if assert.NoError(t, err) {
assert.Equal(t, TTL(24*time.Hour), ttl)
}
})
}