blob: f4052e09707d67efdc648b3b52113d261dc49979 [file] [log] [blame]
Jon Perrittf050a4c2014-09-11 15:01:17 -05001// +build acceptance
2
3package v1
4
5import (
6 "strings"
7 "testing"
8
9 "github.com/rackspace/gophercloud/openstack/storage/v1/accounts"
10)
11
12func TestAccounts(t *testing.T) {
13 client, err := newClient()
14 if err != nil {
15 t.Error(err)
16 return
17 }
18
19 err = accounts.Update(client, accounts.UpdateOpts{
20 Metadata: metadata,
21 })
22 if err != nil {
23 t.Error(err)
24 return
25 }
26 defer func() {
27 tempMap := make(map[string]string)
28 for k := range metadata {
29 tempMap[k] = ""
30 }
31 err = accounts.Update(client, accounts.UpdateOpts{
32 Metadata: tempMap,
33 })
34 if err != nil {
35 t.Error(err)
36 return
37 }
38 }()
39
40 gr, err := accounts.Get(client, accounts.GetOpts{})
41 if err != nil {
42 t.Error(err)
43 return
44 }
45 am := accounts.ExtractMetadata(gr)
46 for k := range metadata {
47 if am[k] != metadata[strings.Title(k)] {
48 t.Errorf("Expected custom metadata with key: %s", k)
49 return
50 }
51 }
52}