-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathstorage_test.go
More file actions
53 lines (47 loc) · 937 Bytes
/
Copy pathstorage_test.go
File metadata and controls
53 lines (47 loc) · 937 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package s2
import (
"context"
"testing"
"github.com/stretchr/testify/assert"
)
type nilStorage struct {
Storage
}
var _ Storage = (*nilStorage)(nil)
func TestNewStorage(t *testing.T) {
testType := Type("test")
RegisterNewStorageFunc(testType, func(ctx context.Context, cfg Config) (Storage, error) {
return &nilStorage{}, nil
})
defer UnregisterNewStorageFunc(testType)
testCases := []struct {
caseName string
ctx context.Context
cfg Config
wantErr string
}{
{
caseName: "typical",
cfg: Config{
Type: testType,
},
},
{
caseName: "unknown type",
cfg: Config{
Type: "UNKNOWN",
},
wantErr: "s2: unknown storage type: UNKNOWN",
},
}
for _, tc := range testCases {
t.Run(tc.caseName, func(t *testing.T) {
_, err := NewStorage(tc.ctx, tc.cfg)
if tc.wantErr != "" {
assert.EqualError(t, err, tc.wantErr)
return
}
assert.NoError(t, err)
})
}
}