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 | |
| 16 | headers, err := raxAccounts.Update(c, raxAccounts.UpdateOpts{Metadata: map[string]string{"white": "mountains"}}).ExtractHeaders() |
| 17 | th.AssertNoErr(t, err) |
| 18 | t.Logf("Headers from Update Account request: %+v\n", headers) |
| 19 | defer func() { |
| 20 | _, err := raxAccounts.Update(c, raxAccounts.UpdateOpts{Metadata: map[string]string{"white": ""}}).ExtractHeaders() |
| 21 | th.AssertNoErr(t, err) |
| 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 | |
| 28 | getResult := raxAccounts.Get(c) |
| 29 | headers, err = getResult.ExtractHeaders() |
| 30 | th.AssertNoErr(t, err) |
| 31 | t.Logf("Headers from Get Account request (after update): %+v\n", headers) |
| 32 | metadata, err := getResult.ExtractMetadata() |
| 33 | th.AssertNoErr(t, err) |
| 34 | t.Logf("Metadata from Get Account request (after update): %+v\n", metadata) |
| 35 | |
| 36 | th.CheckEquals(t, metadata["White"], "mountains") |
| 37 | } |