-
Notifications
You must be signed in to change notification settings - Fork 0
/
registry_test.go
46 lines (37 loc) · 1.21 KB
/
registry_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
package fs
import (
"path/filepath"
"testing"
"github.com/stretchr/testify/assert"
)
func TestParseRawURI(t *testing.T) {
fs, fsPath := ParseRawURI("")
assert.Equal(t, InvalidFileSystem(""), fs)
assert.Equal(t, "", fsPath)
fs, fsPath = ParseRawURI("/")
assert.Equal(t, Local, fs)
assert.Equal(t, "/", fsPath)
fs, fsPath = ParseRawURI(filepath.Join(string(filepath.Separator), "a", "b"))
assert.Equal(t, Local, fs)
assert.Equal(t, filepath.Join(string(filepath.Separator), "a", "b"), fsPath)
testFS := InvalidFileSystem("test")
longerTestFS := InvalidFileSystem("longerTest")
Register(testFS)
Register(longerTestFS)
t.Cleanup(func() {
Unregister(testFS)
Unregister(longerTestFS)
})
assert.Equal(t, Invalid, GetFileSystem("invalid://"))
assert.Equal(t, testFS, GetFileSystem("invalid://test/"))
assert.Equal(t, longerTestFS, GetFileSystem("invalid://longerTest/"))
fs, fsPath = ParseRawURI("invalid://file")
assert.Equal(t, Invalid, fs)
assert.Equal(t, "file", fsPath)
fs, fsPath = ParseRawURI("invalid://test/file")
assert.Equal(t, testFS, fs)
assert.Equal(t, "file", fsPath)
fs, fsPath = ParseRawURI("invalid://longerTest/file")
assert.Equal(t, longerTestFS, fs)
assert.Equal(t, "file", fsPath)
}