| 152 | } |
| 153 | |
| 154 | func TestDestOptions(t *testing.T) { |
| 155 | userMetadata := map[string]string{ |
| 156 | "test": "test", |
| 157 | "x-amz-acl": "public-read-write", |
| 158 | "content-type": "application/binary", |
| 159 | "X-Amz-Storage-Class": "rrs", |
| 160 | "x-amz-grant-write": "test@exo.ch", |
| 161 | } |
| 162 | |
| 163 | r := make(http.Header) |
| 164 | |
| 165 | dst := CopyDestOptions{ |
| 166 | Bucket: "bucket", |
| 167 | Object: "object", |
| 168 | ReplaceMetadata: true, |
| 169 | UserMetadata: userMetadata, |
| 170 | } |
| 171 | dst.Marshal(r) |
| 172 | |
| 173 | if v := r.Get("x-amz-metadata-directive"); v != "REPLACE" { |
| 174 | t.Errorf("Test - metadata directive was expected but is missing") |
| 175 | } |
| 176 | |
| 177 | for k := range r { |
| 178 | if strings.HasSuffix(k, "test") && !strings.HasPrefix(k, "x-amz-meta-") { |
| 179 | t.Errorf("Test meta %q was expected as an x amz meta", k) |
| 180 | } |
| 181 | |
| 182 | if !strings.HasSuffix(k, "test") && strings.HasPrefix(k, "x-amz-meta-") { |
| 183 | t.Errorf("Test an amz/standard/storageClass Header was expected but got an x amz meta data") |
| 184 | } |
| 185 | } |
| 186 | } |