Unit test for ListObjectVersions
(obj ObjectLayer, instanceType string, t1 TestErrHandler)
| 1106 | |
| 1107 | // Unit test for ListObjectVersions |
| 1108 | func testListObjectVersions(obj ObjectLayer, instanceType string, t1 TestErrHandler) { |
| 1109 | t, _ := t1.(*testing.T) |
| 1110 | testBuckets := []string{ |
| 1111 | // This bucket is used for testing ListObject operations. |
| 1112 | "test-bucket-list-object", |
| 1113 | // This bucket will be tested with empty directories |
| 1114 | "test-bucket-empty-dir", |
| 1115 | // Will not store any objects in this bucket, |
| 1116 | // Its to test ListObjects on an empty bucket. |
| 1117 | "empty-bucket", |
| 1118 | // Listing the case where the marker > last object. |
| 1119 | "test-bucket-single-object", |
| 1120 | // Listing uncommon delimiter. |
| 1121 | "test-bucket-delimiter", |
| 1122 | // Listing prefixes > maxKeys |
| 1123 | "test-bucket-max-keys-prefixes", |
| 1124 | } |
| 1125 | for _, bucket := range testBuckets { |
| 1126 | err := obj.MakeBucket(context.Background(), bucket, MakeBucketOptions{VersioningEnabled: true}) |
| 1127 | if err != nil { |
| 1128 | t.Fatalf("%s : %s", instanceType, err.Error()) |
| 1129 | } |
| 1130 | } |
| 1131 | |
| 1132 | var err error |
| 1133 | testObjects := []struct { |
| 1134 | parentBucket string |
| 1135 | name string |
| 1136 | content string |
| 1137 | meta map[string]string |
| 1138 | }{ |
| 1139 | {testBuckets[0], "Asia-maps.png", "asis-maps", map[string]string{"content-type": "image/png"}}, |
| 1140 | {testBuckets[0], "Asia/India/India-summer-photos-1", "contentstring", nil}, |
| 1141 | {testBuckets[0], "Asia/India/Karnataka/Bangalore/Koramangala/pics", "contentstring", nil}, |
| 1142 | {testBuckets[0], "newPrefix0", "newPrefix0", nil}, |
| 1143 | {testBuckets[0], "newPrefix1", "newPrefix1", nil}, |
| 1144 | {testBuckets[0], "newzen/zen/recurse/again/again/again/pics", "recurse", nil}, |
| 1145 | {testBuckets[0], "obj0", "obj0", nil}, |
| 1146 | {testBuckets[0], "obj1", "obj1", nil}, |
| 1147 | {testBuckets[0], "obj2", "obj2", nil}, |
| 1148 | {testBuckets[1], "obj1", "obj1", nil}, |
| 1149 | {testBuckets[1], "obj2", "obj2", nil}, |
| 1150 | {testBuckets[1], "temporary/0/", "", nil}, |
| 1151 | {testBuckets[3], "A/B", "contentstring", nil}, |
| 1152 | {testBuckets[4], "file1/receipt.json", "content", nil}, |
| 1153 | {testBuckets[4], "file1/guidSplunk-aaaa/file", "content", nil}, |
| 1154 | {testBuckets[5], "dir/day_id=2017-10-10/issue", "content", nil}, |
| 1155 | {testBuckets[5], "dir/day_id=2017-10-11/issue", "content", nil}, |
| 1156 | } |
| 1157 | |
| 1158 | for _, object := range testObjects { |
| 1159 | md5Bytes := md5.Sum([]byte(object.content)) |
| 1160 | _, err = obj.PutObject(context.Background(), object.parentBucket, object.name, mustGetPutObjReader(t, bytes.NewBufferString(object.content), |
| 1161 | int64(len(object.content)), hex.EncodeToString(md5Bytes[:]), ""), ObjectOptions{UserDefined: object.meta}) |
| 1162 | if err != nil { |
| 1163 | t.Fatalf("%s : %s", instanceType, err.Error()) |
| 1164 | } |
| 1165 |
nothing calls this directly
no test coverage detected