Jon Perritt | 70bba63 | 2014-09-13 00:32:32 -0500 | [diff] [blame] | 1 | package accounts |
| 2 | |
| 3 | import ( |
Jon Perritt | 70bba63 | 2014-09-13 00:32:32 -0500 | [diff] [blame] | 4 | "testing" |
| 5 | |
Jon Perritt | 4a59d23 | 2014-10-09 20:21:31 -0500 | [diff] [blame] | 6 | th "github.com/rackspace/gophercloud/testhelper" |
Jamie Hannaford | 496ad13 | 2014-10-06 16:20:15 +0200 | [diff] [blame] | 7 | fake "github.com/rackspace/gophercloud/testhelper/client" |
Jon Perritt | 70bba63 | 2014-09-13 00:32:32 -0500 | [diff] [blame] | 8 | ) |
| 9 | |
Jon Perritt | 70bba63 | 2014-09-13 00:32:32 -0500 | [diff] [blame] | 10 | var metadata = map[string]string{"gophercloud-test": "accounts"} |
| 11 | |
Jon Perritt | 70bba63 | 2014-09-13 00:32:32 -0500 | [diff] [blame] | 12 | func TestUpdateAccount(t *testing.T) { |
Jon Perritt | 4a59d23 | 2014-10-09 20:21:31 -0500 | [diff] [blame] | 13 | th.SetupHTTP() |
| 14 | defer th.TeardownHTTP() |
Jon Perritt | 457f8ca | 2014-10-15 00:28:23 -0500 | [diff] [blame] | 15 | HandleGetAccountSuccessfully(t) |
Jon Perritt | 70bba63 | 2014-09-13 00:32:32 -0500 | [diff] [blame] | 16 | |
Jon Perritt | 4a59d23 | 2014-10-09 20:21:31 -0500 | [diff] [blame] | 17 | options := &UpdateOpts{Metadata: map[string]string{"gophercloud-test": "accounts"}} |
Jon Perritt | 7e70c40 | 2014-10-24 16:15:09 -0500 | [diff] [blame^] | 18 | res := Update(fake.ServiceClient(), options) |
| 19 | th.AssertNoErr(t, res.Err) |
Jon Perritt | 70bba63 | 2014-09-13 00:32:32 -0500 | [diff] [blame] | 20 | } |
| 21 | |
| 22 | func TestGetAccount(t *testing.T) { |
Jon Perritt | 4a59d23 | 2014-10-09 20:21:31 -0500 | [diff] [blame] | 23 | th.SetupHTTP() |
| 24 | defer th.TeardownHTTP() |
Jon Perritt | 457f8ca | 2014-10-15 00:28:23 -0500 | [diff] [blame] | 25 | HandleUpdateAccountSuccessfully(t) |
Jon Perritt | 70bba63 | 2014-09-13 00:32:32 -0500 | [diff] [blame] | 26 | |
Jon Perritt | 4a59d23 | 2014-10-09 20:21:31 -0500 | [diff] [blame] | 27 | 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 Hannaford | 93209fe | 2014-10-10 11:54:19 +0200 | [diff] [blame] | 33 | } |