-
Notifications
You must be signed in to change notification settings - Fork 13
/
volume_test.go
39 lines (36 loc) · 925 Bytes
/
volume_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
package meli
import (
"context"
"io/ioutil"
"testing"
)
func TestCreateDockerVolume(t *testing.T) {
tt := []struct {
name string
driver string
expected string
expectedErr error
}{
{"MyVolumeName", "local", "MyVolume007", nil},
}
var ctx = context.Background()
cli := &mockDockerClient{}
dst := ioutil.Discard
for _, v := range tt {
actual, err := CreateDockerVolume(ctx, cli, v.name, v.driver, dst)
if err != nil {
t.Errorf("\nCalled CreateDockerVolume(%#+v) \ngot %s \nwanted %#+v", v.name, err, v.expectedErr)
}
if actual != v.expected {
t.Errorf("\nCalled CreateDockerVolume(%#+v) \ngot %#+v \nwanted %#+v", v.name, actual, v.expected)
}
}
}
func BenchmarkCreateDockerVolume(b *testing.B) {
var ctx = context.Background()
cli := &mockDockerClient{}
dst := ioutil.Discard
for n := 0; n < b.N; n++ {
_, _ = CreateDockerVolume(ctx, cli, "name", "local", dst)
}
}