-
Notifications
You must be signed in to change notification settings - Fork 38
/
main_test.go
73 lines (56 loc) · 1.7 KB
/
main_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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
package main
import (
"testing"
"github.com/stretchr/testify/require"
)
func TestParseURI(t *testing.T) {
t.Log("parseURI - file://../../../../../../Downloads/key.json")
{
keyPth, isRemote, err := parseURI("file://../../../../../../Downloads/key.json")
require.NoError(t, err)
require.Equal(t, "../../../../../../Downloads/key.json", keyPth)
require.Equal(t, false, isRemote)
}
t.Log("parseURI - file://./")
{
keyPth, isRemote, err := parseURI("file://./testfolder/key.json")
require.NoError(t, err)
require.Equal(t, "./testfolder/key.json", keyPth)
require.Equal(t, false, isRemote)
}
t.Log("parseURI - file:///")
{
keyPth, isRemote, err := parseURI("file:///testfolder/key.json")
require.NoError(t, err)
require.Equal(t, "/testfolder/key.json", keyPth)
require.Equal(t, false, isRemote)
}
t.Log("parseURI - http://")
{
keyPth, isRemote, err := parseURI("http://testdomain.com/testsub/key.json")
require.NoError(t, err)
require.Equal(t, "http://testdomain.com/testsub/key.json", keyPth)
require.Equal(t, true, isRemote)
}
t.Log("parseURI - https://")
{
keyPth, isRemote, err := parseURI("https://testdomain.com/testsub/key.json")
require.NoError(t, err)
require.Equal(t, "https://testdomain.com/testsub/key.json", keyPth)
require.Equal(t, true, isRemote)
}
t.Log("parseURI - ./")
{
keyPth, isRemote, err := parseURI("./user/test/key.json")
require.NoError(t, err)
require.Equal(t, "./user/test/key.json", keyPth)
require.Equal(t, false, isRemote)
}
t.Log("parseURI - /")
{
keyPth, isRemote, err := parseURI("/user/test/key.json")
require.NoError(t, err)
require.Equal(t, "/user/test/key.json", keyPth)
require.Equal(t, false, isRemote)
}
}