blob: 145e4e0482cdd2913fcba20a9f6fc57fae752380 [file] [log] [blame]
Jon Perritt8abd2c22014-10-16 20:28:51 -05001// +build acceptance rackspace
2
3package v1
4
5import (
6 "testing"
7
8 raxAccounts "github.com/rackspace/gophercloud/rackspace/objectstorage/v1/accounts"
9 th "github.com/rackspace/gophercloud/testhelper"
10)
11
12func TestAccounts(t *testing.T) {
13 c, err := createClient(t, false)
14 th.AssertNoErr(t, err)
15
Jon Perritt7e70c402014-10-24 16:15:09 -050016 updateres := raxAccounts.Update(c, raxAccounts.UpdateOpts{Metadata: map[string]string{"white": "mountains"}})
17 th.AssertNoErr(t, updateres.Err)
18 t.Logf("Headers from Update Account request: %+v\n", updateres.Header)
Jon Perritt8abd2c22014-10-16 20:28:51 -050019 defer func() {
Jon Perritt7e70c402014-10-24 16:15:09 -050020 updateres = raxAccounts.Update(c, raxAccounts.UpdateOpts{Metadata: map[string]string{"white": ""}})
21 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
Ash Wilsonfef72b82014-10-24 15:46:45 -040028 metadata, err := raxAccounts.Get(c).ExtractMetadata()
Jon Perritt8abd2c22014-10-16 20:28:51 -050029 th.AssertNoErr(t, err)
30 t.Logf("Metadata from Get Account request (after update): %+v\n", metadata)
31
32 th.CheckEquals(t, metadata["White"], "mountains")
33}