tests using the minio client
(t *testing.T)
| 74 | |
| 75 | // tests using the minio client |
| 76 | func 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{ |
nothing calls this directly
no test coverage detected
searching dependent graphs…