Jon Perritt | 0ce24ad | 2014-10-20 21:59:45 -0500 | [diff] [blame] | 1 | package bulk |
| 2 | |
| 3 | import ( |
| 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 | |
| 12 | func 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 Perritt | 260e088 | 2014-10-20 23:31:23 -0500 | [diff] [blame] | 18 | th.AssertEquals(t, r.URL.RawQuery, "bulk-delete") |
Jon Perritt | 0ce24ad | 2014-10-20 21:59:45 -0500 | [diff] [blame] | 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 | |
Jon Perritt | 260e088 | 2014-10-20 23:31:23 -0500 | [diff] [blame] | 32 | options := DeleteOpts{"gophercloud-testcontainer1", "gophercloud-testcontainer2"} |
Jon Perritt | 0ce24ad | 2014-10-20 21:59:45 -0500 | [diff] [blame] | 33 | actual, err := Delete(fake.ServiceClient(), options).ExtractBody() |
| 34 | th.AssertNoErr(t, err) |
| 35 | th.AssertEquals(t, actual.NumberDeleted, 1) |
| 36 | } |