File: base_endpoint_test.go

package info (click to toggle)
golang-github-gophercloud-gophercloud 0.0~git20180917.45f1c769-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 7,768 kB
  • sloc: sh: 98; makefile: 14
file content (88 lines) | stat: -rw-r--r-- 2,201 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
package testing

import (
	"testing"

	"github.com/gophercloud/gophercloud/openstack/utils"
	th "github.com/gophercloud/gophercloud/testhelper"
)

type endpointTestCases struct {
	Endpoint     string
	BaseEndpoint string
}

func TestBaseEndpoint(t *testing.T) {
	tests := []endpointTestCases{
		{
			Endpoint:     "http://example.com:5000/v3",
			BaseEndpoint: "http://example.com:5000/",
		},
		{
			Endpoint:     "http://example.com:5000/v3.6",
			BaseEndpoint: "http://example.com:5000/",
		},
		{
			Endpoint:     "http://example.com:5000/v2.0",
			BaseEndpoint: "http://example.com:5000/",
		},
		{
			Endpoint:     "http://example.com:5000/",
			BaseEndpoint: "http://example.com:5000/",
		},
		{
			Endpoint:     "http://example.com:5000",
			BaseEndpoint: "http://example.com:5000",
		},
		{
			Endpoint:     "http://example.com/identity/v3",
			BaseEndpoint: "http://example.com/identity/",
		},
		{
			Endpoint:     "http://example.com/identity/v3.6",
			BaseEndpoint: "http://example.com/identity/",
		},
		{
			Endpoint:     "http://example.com/identity/v2.0",
			BaseEndpoint: "http://example.com/identity/",
		},
		{
			Endpoint:     "http://example.com/identity/v2.0/projects",
			BaseEndpoint: "http://example.com/identity/",
		},
		{
			Endpoint:     "http://example.com/v2.0/projects",
			BaseEndpoint: "http://example.com/",
		},
		{
			Endpoint:     "http://example.com/identity/",
			BaseEndpoint: "http://example.com/identity/",
		},
		{
			Endpoint:     "http://dev.example.com:5000/v3",
			BaseEndpoint: "http://dev.example.com:5000/",
		},
		{
			Endpoint:     "http://dev.example.com:5000/v3.6",
			BaseEndpoint: "http://dev.example.com:5000/",
		},
		{
			Endpoint:     "http://dev.example.com/identity/",
			BaseEndpoint: "http://dev.example.com/identity/",
		},
		{
			Endpoint:     "http://dev.example.com/identity/v2.0/projects",
			BaseEndpoint: "http://dev.example.com/identity/",
		},
		{
			Endpoint:     "http://dev.example.com/identity/v3.6",
			BaseEndpoint: "http://dev.example.com/identity/",
		},
	}

	for _, test := range tests {
		actual, err := utils.BaseEndpoint(test.Endpoint)
		th.AssertNoErr(t, err)
		th.AssertEquals(t, test.BaseEndpoint, actual)
	}
}