-
Notifications
You must be signed in to change notification settings - Fork 2
/
miniotest_test.go
64 lines (48 loc) · 1.35 KB
/
miniotest_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
53
54
55
56
57
58
59
60
61
62
63
64
package miniotest_test
import (
"bytes"
"context"
"fmt"
"os"
"testing"
"github.com/draganm/miniotest"
mclient "github.com/minio/minio-go/v7"
"github.com/minio/minio-go/v7/pkg/credentials"
"github.com/stretchr/testify/require"
)
func Test(t *testing.T) {
mc, err := mclient.New(addr, &mclient.Options{
Creds: credentials.NewStaticV4("minioadmin", "minioadmin", ""),
Secure: false,
})
require.NoError(t, err)
data := []byte("test")
_, err = mc.PutObject(context.Background(), "test", "foo/var", bytes.NewReader(data), int64(len(data)), mclient.PutObjectOptions{})
require.NoError(t, err)
}
func Test2(t *testing.T) {
mc, err := mclient.New(addr, &mclient.Options{
Creds: credentials.NewStaticV4("minioadmin", "minioadmin", ""),
Secure: false,
})
require.NoError(t, err)
data := []byte("test")
_, err = mc.PutObject(context.Background(), "test", "foo/var", bytes.NewReader(data), int64(len(data)), mclient.PutObjectOptions{})
require.NoError(t, err)
}
var addr string
func TestMain(m *testing.M) {
var cleanup func() error
var err error
addr, cleanup, err = miniotest.StartEmbedded()
if err != nil {
fmt.Fprintf(os.Stderr, "while starting embedded server: %s", err)
os.Exit(1)
}
exitCode := m.Run()
err = cleanup()
if err != nil {
fmt.Fprintf(os.Stderr, "while stopping embedded server: %s", err)
}
os.Exit(exitCode)
}