-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoptions_test.go
52 lines (46 loc) · 1.17 KB
/
options_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
package blockstorage
import (
"testing"
mockpeer "github.com/igumus/blockstorage/peer/mock"
"github.com/igumus/go-objectstore-lib/mock"
"github.com/stretchr/testify/require"
)
func (s *blockStorageSuite) TestBlockStorageConfigCreation() {
store := mock.NewMockObjectStore(s.ctrl)
peer := mockpeer.NewMockBlockStoragePeer(s.ctrl)
testCases := []struct {
name string
shouldFail bool
options []BlockStorageOption
err error
}{
{
name: "empty_options",
options: make([]BlockStorageOption, 0),
shouldFail: true,
err: ErrLocalObjectStoreNotDefined,
},
{
name: "without_peer",
options: append([]BlockStorageOption{}, WithLocalStore(store)),
shouldFail: true,
err: ErrPeerNotSpecified,
},
{
name: "valid_options",
options: append([]BlockStorageOption{}, WithLocalStore(store), WithPeer(peer)),
shouldFail: false,
err: nil,
},
}
for i := range testCases {
tc := testCases[i]
s.T().Run(tc.name, func(t *testing.T) {
cfg, err := createConfig(tc.options...)
if !tc.shouldFail {
require.NotNil(s.T(), cfg)
}
require.Equal(s.T(), tc.err, err)
})
}
}