blob: 8aba5910dfcb5ca2c7a1f243ae1ac9260a09d514 [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 Perritt27249f42016-02-18 10:35:59 -06006 th "github.com/gophercloud/gophercloud/testhelper"
7 fake "github.com/gophercloud/gophercloud/testhelper/client"
Jon Perritt70bba632014-09-13 00:32:32 -05008)
9
Jon Perritt70bba632014-09-13 00:32:32 -050010func TestUpdateAccount(t *testing.T) {
Jon Perritt4a59d232014-10-09 20:21:31 -050011 th.SetupHTTP()
12 defer th.TeardownHTTP()
Jon Perrittae06ab72014-11-06 18:18:55 -060013 HandleUpdateAccountSuccessfully(t)
Jon Perritt70bba632014-09-13 00:32:32 -050014
Jon Perritt4a59d232014-10-09 20:21:31 -050015 options := &UpdateOpts{Metadata: map[string]string{"gophercloud-test": "accounts"}}
Jon Perritt3c166472016-02-25 03:07:41 -060016 _, err := Update(fake.ServiceClient(), options).Extract()
17 th.AssertNoErr(t, err)
Jon Perritt70bba632014-09-13 00:32:32 -050018}
19
20func TestGetAccount(t *testing.T) {
Jon Perritt4a59d232014-10-09 20:21:31 -050021 th.SetupHTTP()
22 defer th.TeardownHTTP()
Jon Perrittae06ab72014-11-06 18:18:55 -060023 HandleGetAccountSuccessfully(t)
Jon Perritt70bba632014-09-13 00:32:32 -050024
Jon Perrittae06ab72014-11-06 18:18:55 -060025 expectedMetadata := map[string]string{"Subject": "books"}
26 res := Get(fake.ServiceClient(), &GetOpts{})
27 th.AssertNoErr(t, res.Err)
28 actualMetadata, _ := res.ExtractMetadata()
29 th.CheckDeepEquals(t, expectedMetadata, actualMetadata)
Jon Perritt3c166472016-02-25 03:07:41 -060030 _, err := res.Extract()
31 th.AssertNoErr(t, err)
Jamie Hannaford93209fe2014-10-10 11:54:19 +020032}