-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlink_test.go
More file actions
39 lines (34 loc) · 820 Bytes
/
Copy pathlink_test.go
File metadata and controls
39 lines (34 loc) · 820 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
package siren_test
import (
"errors"
"testing"
. "github.com/dominicbarnes/go-siren"
"github.com/stretchr/testify/require"
)
func TestLinkValidate(t *testing.T) {
RunValidatorTests(t, map[string]ValidatorSpec{
"valid": {
Input: Link{Href: "/", Rel: Rels{"self"}},
},
"missing href": {
Input: Link{Rel: Rels{"self"}},
Expected: errors.New("Href: zero value"),
},
"missing rel": {
Input: Link{Href: "/"},
Expected: errors.New("Rel: zero value"),
},
})
}
func TestLinkWithBaseHref(t *testing.T) {
l := Link{
Href: "/",
Rel: Rels{"self", "/rels/custom"},
}
expected := Link{
Href: "https://api.example.com/",
Rel: Rels{"self", "https://api.example.com/rels/custom"},
}
actual := l.WithBaseHref("https://api.example.com")
require.EqualValues(t, expected, actual)
}