blob: d6dc26b650e77ce76152fc5a8370fbfb42a6ae66 [file] [log] [blame]
Jon Perritt70bba632014-09-13 00:32:32 -05001package accounts
2
3import (
Jon Perritt70bba632014-09-13 00:32:32 -05004 "testing"
5
Jon Perritt4a59d232014-10-09 20:21:31 -05006 th "github.com/rackspace/gophercloud/testhelper"
Jamie Hannaford496ad132014-10-06 16:20:15 +02007 fake "github.com/rackspace/gophercloud/testhelper/client"
Jon Perritt70bba632014-09-13 00:32:32 -05008)
9
Jon Perritt70bba632014-09-13 00:32:32 -050010var metadata = map[string]string{"gophercloud-test": "accounts"}
11
Jon Perritt70bba632014-09-13 00:32:32 -050012func TestUpdateAccount(t *testing.T) {
Jon Perritt4a59d232014-10-09 20:21:31 -050013 th.SetupHTTP()
14 defer th.TeardownHTTP()
Jon Perritt457f8ca2014-10-15 00:28:23 -050015 HandleGetAccountSuccessfully(t)
Jon Perritt70bba632014-09-13 00:32:32 -050016
Jon Perritt4a59d232014-10-09 20:21:31 -050017 options := &UpdateOpts{Metadata: map[string]string{"gophercloud-test": "accounts"}}
Jon Perritt7e70c402014-10-24 16:15:09 -050018 res := Update(fake.ServiceClient(), options)
19 th.AssertNoErr(t, res.Err)
Jon Perritt70bba632014-09-13 00:32:32 -050020}
21
22func TestGetAccount(t *testing.T) {
Jon Perritt4a59d232014-10-09 20:21:31 -050023 th.SetupHTTP()
24 defer th.TeardownHTTP()
Jon Perritt457f8ca2014-10-15 00:28:23 -050025 HandleUpdateAccountSuccessfully(t)
Jon Perritt70bba632014-09-13 00:32:32 -050026
Jon Perritt4a59d232014-10-09 20:21:31 -050027 expected := map[string]string{"Foo": "bar"}
28 actual, err := Get(fake.ServiceClient(), &GetOpts{}).ExtractMetadata()
29 if err != nil {
30 t.Fatalf("Unable to get account metadata: %v", err)
31 }
32 th.CheckDeepEquals(t, expected, actual)
Jamie Hannaford93209fe2014-10-10 11:54:19 +020033}