blob: 2d7b8f05ead3221c386cbf023eaa879c74fe4817 [file] [log] [blame]
Jon Perritt8abd2c22014-10-16 20:28:51 -05001// +build acceptance rackspace
2
3package v1
4
5import (
6 "testing"
7
Jon Perritt27249f42016-02-18 10:35:59 -06008 raxAccounts "github.com/gophercloud/gophercloud/rackspace/objectstorage/v1/accounts"
9 th "github.com/gophercloud/gophercloud/testhelper"
Jon Perritt8abd2c22014-10-16 20:28:51 -050010)
11
12func TestAccounts(t *testing.T) {
13 c, err := createClient(t, false)
14 th.AssertNoErr(t, err)
15
Jon Perritta3de08f2014-12-17 22:08:19 -070016 updateHeaders, err := raxAccounts.Update(c, raxAccounts.UpdateOpts{Metadata: map[string]string{"white": "mountains"}}).Extract()
Jon Perritt63e7a482014-12-04 09:47:23 -070017 th.AssertNoErr(t, err)
18 t.Logf("Update Account Response Headers: %+v\n", updateHeaders)
Jon Perritt8abd2c22014-10-16 20:28:51 -050019 defer func() {
Jon Perritta3de08f2014-12-17 22:08:19 -070020 updateres := raxAccounts.Update(c, raxAccounts.UpdateOpts{Metadata: map[string]string{"white": ""}})
Jon Perritt7e70c402014-10-24 16:15:09 -050021 th.AssertNoErr(t, updateres.Err)
Jon Perritt8abd2c22014-10-16 20:28:51 -050022 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 Perritta3de08f2014-12-17 22:08:19 -070028 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 Perritt8abd2c22014-10-16 20:28:51 -050035 t.Logf("Metadata from Get Account request (after update): %+v\n", metadata)
36
37 th.CheckEquals(t, metadata["White"], "mountains")
38}