Jon Perritt | 8abd2c2 | 2014-10-16 20:28:51 -0500 | [diff] [blame] | 1 | // +build acceptance rackspace |
| 2 | |
| 3 | package v1 |
| 4 | |
| 5 | import ( |
| 6 | "testing" |
| 7 | |
| 8 | raxAccounts "github.com/rackspace/gophercloud/rackspace/objectstorage/v1/accounts" |
| 9 | th "github.com/rackspace/gophercloud/testhelper" |
| 10 | ) |
| 11 | |
| 12 | func TestAccounts(t *testing.T) { |
| 13 | c, err := createClient(t, false) |
| 14 | th.AssertNoErr(t, err) |
| 15 | |
Jon Perritt | a3de08f | 2014-12-17 22:08:19 -0700 | [diff] [blame] | 16 | updateHeaders, err := raxAccounts.Update(c, raxAccounts.UpdateOpts{Metadata: map[string]string{"white": "mountains"}}).Extract() |
Jon Perritt | 63e7a48 | 2014-12-04 09:47:23 -0700 | [diff] [blame] | 17 | th.AssertNoErr(t, err) |
| 18 | t.Logf("Update Account Response Headers: %+v\n", updateHeaders) |
Jon Perritt | 8abd2c2 | 2014-10-16 20:28:51 -0500 | [diff] [blame] | 19 | defer func() { |
Jon Perritt | a3de08f | 2014-12-17 22:08:19 -0700 | [diff] [blame] | 20 | updateres := raxAccounts.Update(c, raxAccounts.UpdateOpts{Metadata: map[string]string{"white": ""}}) |
Jon Perritt | 7e70c40 | 2014-10-24 16:15:09 -0500 | [diff] [blame] | 21 | th.AssertNoErr(t, updateres.Err) |
Jon Perritt | 8abd2c2 | 2014-10-16 20:28:51 -0500 | [diff] [blame] | 22 | metadata, err := raxAccounts.Get(c).ExtractMetadata() |
| 23 | th.AssertNoErr(t, err) |
| 24 | t.Logf("Metadata from Get Account request (after update reverted): %+v\n", metadata) |
| 25 | th.CheckEquals(t, metadata["White"], "") |
| 26 | }() |
| 27 | |
Jon Perritt | a3de08f | 2014-12-17 22:08:19 -0700 | [diff] [blame] | 28 | getResp := raxAccounts.Get(c) |
| 29 | th.AssertNoErr(t, getResp.Err) |
| 30 | |
| 31 | getHeaders, _ := getResp.Extract() |
| 32 | t.Logf("Get Account Response Headers: %+v\n", getHeaders) |
| 33 | |
| 34 | metadata, _ := getResp.ExtractMetadata() |
Jon Perritt | 8abd2c2 | 2014-10-16 20:28:51 -0500 | [diff] [blame] | 35 | t.Logf("Metadata from Get Account request (after update): %+v\n", metadata) |
| 36 | |
| 37 | th.CheckEquals(t, metadata["White"], "mountains") |
| 38 | } |