1package testing 2 3import ( 4 "testing" 5 6 "github.com/gophercloud/utils/openstack/clientconfig" 7 8 th "github.com/gophercloud/gophercloud/testhelper" 9 yaml "gopkg.in/yaml.v2" 10) 11 12var VirginiaExpected = `clouds: 13 virginia: 14 auth: 15 auth_url: https://va.example.com:5000/v3 16 application_credential_id: app-cred-id 17 application_credential_secret: secret 18 auth_type: v3applicationcredential 19 region_name: VA 20 verify: true 21` 22 23var HawaiiExpected = `clouds: 24 hawaii: 25 auth: 26 auth_url: https://hi.example.com:5000/v3 27 username: jdoe 28 password: password 29 project_name: Some Project 30 domain_name: default 31 region_name: HNL 32 verify: true 33` 34 35func TestMarshallCloudToYaml(t *testing.T) { 36 clouds := make(map[string]map[string]*clientconfig.Cloud) 37 clouds["clouds"] = map[string]*clientconfig.Cloud{ 38 "virginia": &VirginiaCloudYAML, 39 } 40 41 marshalled, err := yaml.Marshal(clouds) 42 th.AssertNoErr(t, err) 43 44 th.AssertEquals(t, VirginiaExpected, string(marshalled)) 45 46 clouds["clouds"] = map[string]*clientconfig.Cloud{ 47 "hawaii": &HawaiiCloudYAML, 48 } 49 50 marshalled, err = yaml.Marshal(clouds) 51 th.AssertNoErr(t, err) 52 53 th.AssertEquals(t, HawaiiExpected, string(marshalled)) 54} 55