-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathlocalstore_test.go
49 lines (37 loc) · 1.38 KB
/
localstore_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
package dstore
import (
"context"
"math"
"net/url"
"strings"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestNewLocalStore_SanitizeLocalPath(t *testing.T) {
store, err := NewLocalStore(&url.URL{Scheme: "", Path: "./storetests"}, "go", "", false)
require.NoError(t, err)
files, err := store.ListFiles(context.Background(), "", math.MaxInt64)
require.NoError(t, err)
assert.True(t, len(files) > 0, "Expecting more than one file to be found, got %d", len(files))
}
func TestNewLocalStore_OpenObject_notFound(t *testing.T) {
store, err := NewLocalStore(&url.URL{Scheme: "", Path: "/tmp/storage/"}, "", "", false)
require.NoError(t, err)
_, err = store.OpenObject(context.Background(), "foo.txt")
assert.Equal(t, ErrNotFound, err)
}
func TestNewLocalStore_SubStoreRelative(t *testing.T) {
store, err := NewLocalStore(&url.URL{Scheme: "", Path: "./storage/"}, "", "", false)
require.NoError(t, err)
sub, err := store.SubStore("sub-folder")
require.NoError(t, err)
require.True(t, strings.HasSuffix(sub.BaseURL().Path, "sub-folder"))
}
func TestNewLocalStore_SubStore(t *testing.T) {
store, err := NewLocalStore(&url.URL{Scheme: "", Path: "/tmp/storage/"}, "", "", false)
require.NoError(t, err)
sub, err := store.SubStore("sub-folder")
require.NoError(t, err)
require.True(t, strings.HasSuffix(sub.BaseURL().Path, "sub-folder"))
}