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