forked from git-lfs/git-lfs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathobject_test.go
More file actions
49 lines (40 loc) · 1010 Bytes
/
object_test.go
File metadata and controls
49 lines (40 loc) · 1010 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
package api_test
import (
"testing"
"time"
"github.com/github/git-lfs/api"
"github.com/stretchr/testify/assert"
)
func TestObjectsWithNoActionsAreNotExpired(t *testing.T) {
o := &api.ObjectResource{
Oid: "some-oid",
Actions: map[string]*api.LinkRelation{},
}
assert.False(t, o.IsExpired(time.Now()))
}
func TestObjectsWithZeroValueTimesAreNotExpired(t *testing.T) {
o := &api.ObjectResource{
Oid: "some-oid",
Actions: map[string]*api.LinkRelation{
"upload": &api.LinkRelation{
Href: "http://your-lfs-server.com",
ExpiresAt: time.Time{},
},
},
}
assert.False(t, o.IsExpired(time.Now()))
}
func TestObjectsWithExpirationDatesAreExpired(t *testing.T) {
now := time.Now()
expires := time.Now().Add(-60 * 60 * time.Second)
o := &api.ObjectResource{
Oid: "some-oid",
Actions: map[string]*api.LinkRelation{
"upload": &api.LinkRelation{
Href: "http://your-lfs-server.com",
ExpiresAt: expires,
},
},
}
assert.True(t, o.IsExpired(now))
}