-
Notifications
You must be signed in to change notification settings - Fork 35
/
ldp_test.go
52 lines (44 loc) · 1.72 KB
/
ldp_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
package gold
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestLinkHeaderParser(t *testing.T) {
l := ParseLinkHeader("")
assert.Equal(t, "", l.MatchRel("acl"))
l = ParseLinkHeader("<http://www.w3.org/ns/ldp#Container>; rel='type'")
assert.NotEmpty(t, l.headers)
assert.True(t, l.MatchURI("http://www.w3.org/ns/ldp#Container"))
assert.False(t, l.MatchURI("http://www.w3.org/ns/ldp#Resource"))
assert.Equal(t, "http://www.w3.org/ns/ldp#Container", l.MatchRel("type"))
l = ParseLinkHeader("<http://www.w3.org/ns/ldp#Container>; rel=\"type\", <http://www.w3.org/ns/ldp#Resource>; rel=\"type\"")
assert.NotEmpty(t, l.headers)
assert.True(t, l.MatchURI("http://www.w3.org/ns/ldp#Container"))
assert.True(t, l.MatchURI("http://www.w3.org/ns/ldp#Resource"))
}
func TestPreferHeaderParser(t *testing.T) {
l := ParsePreferHeader("return=representation; omit=\"http://www.w3.org/ns/ldp#PreferMembership http://www.w3.org/ns/ldp#PreferContainment\"")
assert.NotEmpty(t, l.headers)
assert.Equal(t, 2, len(l.Omits()))
for i, uri := range l.Omits() {
if i == 0 {
assert.Equal(t, "http://www.w3.org/ns/ldp#PreferMembership", uri)
} else {
assert.Equal(t, "http://www.w3.org/ns/ldp#PreferContainment", uri)
}
}
l = ParsePreferHeader("return=representation; include=\"http://www.w3.org/ns/ldp#PreferMembership http://www.w3.org/ns/ldp#PreferContainment\"")
assert.NotEmpty(t, l.headers)
assert.Equal(t, 2, len(l.Includes()))
for i, uri := range l.Includes() {
if i == 0 {
assert.Equal(t, "http://www.w3.org/ns/ldp#PreferMembership", uri)
} else {
assert.Equal(t, "http://www.w3.org/ns/ldp#PreferContainment", uri)
}
}
}
func TestNewUUID(t *testing.T) {
uuid := NewUUID()
assert.Equal(t, 32, len(uuid))
}