blob: 8b5578e91e878c38a75e8d9360f564818503e55c [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)
Jon Perritt260e0882014-10-20 23:31:23 -050018 th.AssertEquals(t, r.URL.RawQuery, "bulk-delete")
Jon Perritt0ce24ad2014-10-20 21:59:45 -050019
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
Jon Perritt260e0882014-10-20 23:31:23 -050032 options := DeleteOpts{"gophercloud-testcontainer1", "gophercloud-testcontainer2"}
Jon Perritt0ce24ad2014-10-20 21:59:45 -050033 actual, err := Delete(fake.ServiceClient(), options).ExtractBody()
34 th.AssertNoErr(t, err)
35 th.AssertEquals(t, actual.NumberDeleted, 1)
36}