MCPcopy
hub / github.com/rclone/rclone / TestEncodingWithMinioClient

Function TestEncodingWithMinioClient

cmd/serve/s3/s3_test.go:76–141  ·  view source on GitHub ↗

tests using the minio client

(t *testing.T)

Source from the content-addressed store, hash-verified

74
75// tests using the minio client
76func TestEncodingWithMinioClient(t *testing.T) {
77 cases := []struct {
78 description string
79 bucket string
80 path string
81 filename string
82 expected string
83 }{
84 {
85 description: "weird file in bucket root",
86 bucket: "mybucket",
87 path: "",
88 filename: " file with w€r^d ch@r \\#~+§4%&'. txt ",
89 },
90 {
91 description: "weird file inside a weird folder",
92 bucket: "mybucket",
93 path: "ä#/नेपाल&/?/",
94 filename: " file with w€r^d ch@r \\#~+§4%&'. txt ",
95 },
96 }
97
98 for _, tt := range cases {
99 t.Run(tt.description, func(t *testing.T) {
100 fstest.Initialise()
101 f, _, clean, err := fstest.RandomRemote()
102 assert.NoError(t, err)
103 defer clean()
104 err = f.Mkdir(context.Background(), path.Join(tt.bucket, tt.path))
105 assert.NoError(t, err)
106
107 buf := bytes.NewBufferString("contents")
108 uploadHash := hash.NewMultiHasher()
109 in := io.TeeReader(buf, uploadHash)
110
111 obji := object.NewStaticObjectInfo(
112 path.Join(tt.bucket, tt.path, tt.filename),
113 time.Now(),
114 int64(buf.Len()),
115 true,
116 nil,
117 nil,
118 )
119 _, err = f.Put(context.Background(), in, obji)
120 assert.NoError(t, err)
121
122 endpoint, keyid, keysec, _ := serveS3(t, f)
123 testURL, _ := url.Parse(endpoint)
124 minioClient, err := minio.New(testURL.Host, &minio.Options{
125 Creds: credentials.NewStaticV4(keyid, keysec, ""),
126 Secure: false,
127 })
128 assert.NoError(t, err)
129
130 buckets, err := minioClient.ListBuckets(context.Background())
131 assert.NoError(t, err)
132 assert.Equal(t, buckets[0].Name, tt.bucket)
133 objects := minioClient.ListObjects(context.Background(), tt.bucket, minio.ListObjectsOptions{

Callers

nothing calls this directly

Calls 13

InitialiseFunction · 0.92
RandomRemoteFunction · 0.92
NewMultiHasherFunction · 0.92
NewStaticObjectInfoFunction · 0.92
serveS3Function · 0.85
JoinMethod · 0.80
ListBucketsMethod · 0.80
RunMethod · 0.65
MkdirMethod · 0.65
PutMethod · 0.65
cleanFunction · 0.50
LenMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…