-
Notifications
You must be signed in to change notification settings - Fork 0
/
uri_test.go
48 lines (43 loc) · 907 Bytes
/
uri_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
package uniquefile_test
import (
"testing"
"github.com/skillian/uniquefile"
)
type uriTest struct {
source string
uri uniquefile.URI
}
var uriTests = []uriTest{
{"file:opaque.txt", uniquefile.URI{
Scheme: "file",
Path: "opaque.txt",
}},
{"file://server/share/file.txt", uniquefile.URI{
Scheme: "file",
Hostname: "server",
Path: "/share/file.txt",
}},
}
func TestURI(t *testing.T) {
for _, tc := range uriTests {
t.Run(tc.source, func(t *testing.T) {
u := &uniquefile.URI{}
if err := u.FromString(tc.source); err != nil {
t.Fatal(err)
}
if *u != tc.uri {
t.Fatalf(
"actual URI does not match expected:\n\t%v\n\t%v",
*u, tc.uri,
)
}
s := u.String()
if s != tc.source {
t.Fatalf(
"re-stringed URI doesn't match source:\n\t%v\n\t%v",
s, tc.source,
)
}
})
}
}