File: results_test.go

package info (click to toggle)
golang-github-gophercloud-utils 0.0~git20231010.80377ec-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 816 kB
  • sloc: sh: 20; makefile: 7
file content (54 lines) | stat: -rw-r--r-- 1,215 bytes parent folder | download | duplicates (3)
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))
}