blob: 8598f30ecd32d8189eebb565a46ac43ce97af968 [file] [log] [blame]
Jon Perritt0ce24ad2014-10-20 21:59:45 -05001package bulk
2
3import (
4 "fmt"
5 "net/http"
6 "testing"
7
8 th "github.com/rackspace/gophercloud/testhelper"
9 fake "github.com/rackspace/gophercloud/testhelper/client"
10)
11
12func TestBulkDelete(t *testing.T) {
13 th.SetupHTTP()
14 defer th.TeardownHTTP()
15 th.Mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
16 th.TestMethod(t, r, "DELETE")
17 th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
18 th.AssertEquals(t, r.URL.RawQuery, "bulk-delete")
19
20 w.WriteHeader(http.StatusOK)
21 fmt.Fprintf(w, `
22 {
23 "Number Not Found": 1,
24 "Response Status": "200 OK",
25 "Errors": [],
26 "Number Deleted": 1,
27 "Response Body": ""
28 }
29 `)
30 })
31
32 options := &DeleteOpts{"gophercloud-testcontainer1", "gophercloud-testcontainer2"}
33 actual, err := Delete(fake.ServiceClient(), options).ExtractBody()
34 th.AssertNoErr(t, err)
35 th.AssertEquals(t, actual.NumberDeleted, 1)
36}