forked from fuero/vault
-
Notifications
You must be signed in to change notification settings - Fork 0
/
lease_test.go
56 lines (46 loc) · 1015 Bytes
/
lease_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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package logical
import (
"testing"
"time"
)
func TestLeaseOptionsLeaseTotal(t *testing.T) {
var l LeaseOptions
l.TTL = 1 * time.Hour
actual := l.LeaseTotal()
expected := l.TTL
if actual != expected {
t.Fatalf("bad: %s", actual)
}
}
func TestLeaseOptionsLeaseTotal_grace(t *testing.T) {
var l LeaseOptions
l.TTL = 1 * time.Hour
actual := l.LeaseTotal()
if actual != l.TTL {
t.Fatalf("bad: %s", actual)
}
}
func TestLeaseOptionsLeaseTotal_negLease(t *testing.T) {
var l LeaseOptions
l.TTL = -1 * 1 * time.Hour
actual := l.LeaseTotal()
expected := time.Duration(0)
if actual != expected {
t.Fatalf("bad: %s", actual)
}
}
func TestLeaseOptionsExpirationTime(t *testing.T) {
var l LeaseOptions
l.TTL = 1 * time.Hour
limit := time.Now().Add(time.Hour)
exp := l.ExpirationTime()
if exp.Before(limit) {
t.Fatalf("bad: %s", exp)
}
}
func TestLeaseOptionsExpirationTime_noLease(t *testing.T) {
var l LeaseOptions
if !l.ExpirationTime().IsZero() {
t.Fatal("should be zero")
}
}