/
fixtures.go
76 lines (71 loc) · 2.64 KB
/
fixtures.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
65
66
67
68
69
70
71
72
73
74
75
76
package testing
import (
"fmt"
"net/http"
"testing"
"time"
th "github.com/gophercloud/gophercloud/testhelper"
fake "github.com/gophercloud/gophercloud/testhelper/client"
"github.com/gophercloud/utils/openstack/objectstorage/v1/objects"
)
const multipartManifest = `
[
{
"bytes": 104857600,
"content_type": "application/swiftclient-segment",
"hash": "a8b539f420dc1f47a6721cec22efeab3",
"last_modified": "2018-04-22T01:34:00.000000",
"name": "/testContainer/testObject/slo/1524360755.633149/289669120/104857600/00000000"
},
{
"bytes": 104857600,
"content_type": "application/swiftclient-segment",
"hash": "7fd240a4032a676efd518ffa8601cde1",
"last_modified": "2018-04-22T01:34:00.000000",
"name": "/testContainer/testObject/slo/1524360755.633149/289669120/104857600/00000001"
},
{
"bytes": 79953920,
"content_type": "application/swiftclient-segment",
"hash": "96414e8a758f1ba7107fd03bc5fc4741",
"last_modified": "2018-04-22T01:34:00.000000",
"name": "/testContainer/testObject/slo/1524360755.633149/289669120/104857600/00000002"
}
]
`
var expectedMultipartManifest = []objects.Manifest{
{
Bytes: 104857600,
ContentType: "application/swiftclient-segment",
Hash: "a8b539f420dc1f47a6721cec22efeab3",
LastModified: time.Date(2018, 4, 22, 1, 34, 0, 0, time.UTC),
Name: "/testContainer/testObject/slo/1524360755.633149/289669120/104857600/00000000",
},
{
Bytes: 104857600,
ContentType: "application/swiftclient-segment",
Hash: "7fd240a4032a676efd518ffa8601cde1",
LastModified: time.Date(2018, 4, 22, 1, 34, 0, 0, time.UTC),
Name: "/testContainer/testObject/slo/1524360755.633149/289669120/104857600/00000001",
},
{
Bytes: 79953920,
ContentType: "application/swiftclient-segment",
Hash: "96414e8a758f1ba7107fd03bc5fc4741",
LastModified: time.Date(2018, 4, 22, 1, 34, 0, 0, time.UTC),
Name: "/testContainer/testObject/slo/1524360755.633149/289669120/104857600/00000002",
},
}
// HandleDownloadManifestSuccessfully creates an HTTP handler at
// `/testContainer/testObject` on the test handler mux that responds with a
// Download response.
func HandleDownloadManifestSuccessfully(t *testing.T) {
th.Mux.HandleFunc("/testContainer/testObject", func(w http.ResponseWriter, r *http.Request) {
th.TestMethod(t, r, "GET")
th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
th.TestHeader(t, r, "Accept", "application/json")
w.Header().Set("Date", "Wed, 10 Nov 2009 23:00:00 GMT")
w.WriteHeader(http.StatusOK)
fmt.Fprintf(w, multipartManifest)
})
}