forked from Azure/azure-extensions-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
regions_test.go
69 lines (57 loc) · 1.71 KB
/
regions_test.go
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
package main
import (
"strings"
"testing"
)
func TestNormalizeRegion(t *testing.T) {
if normalizeRegionName("South Central US") != "southcentralus" {
t.Error("Failed to normalize 'South Central US'")
}
if normalizeRegionName("southcentralus") != "southcentralus" {
t.Error("Failed to normalize 'southcentralus'")
}
}
func TestRegionIsExact(t *testing.T) {
testRegions := []string{
"South Central US",
}
regions := normalizeRegionList(testRegions)
if len(regions) != 1 {
t.Fatalf("There should be exactly one region.")
}
if strings.Compare("South Central US", regions[0]) != 0 {
t.Fatalf("Expected the region to by \"South Central US\", but got %q", regions[0])
}
}
func TestRegionMustNormalize(t *testing.T) {
testRegions := []string{
"southcentralus",
"NORTH CENTRAL US",
"uksouth",
}
regions := normalizeRegionList(testRegions)
if len(regions) != 3 {
t.Fatalf("There should be exactly three regions.")
}
if strings.Compare("South Central US", regions[0]) != 0 {
t.Fatalf("Expected the region to by \"South Central US\", but got %q", regions[0])
}
if strings.Compare("North Central US", regions[1]) != 0 {
t.Fatalf("Expected the region to by \"North Central US\", but got %q", regions[1])
}
if strings.Compare("UK South", regions[2]) != 0 {
t.Fatalf("Expected the region to by \"UK South\", but got %q", regions[2])
}
}
func TestUnrecognizedRegionIsPassed(t *testing.T) {
testRegions := []string{
"Candy Land East",
}
regions := normalizeRegionList(testRegions)
if len(regions) != 1 {
t.Fatalf("There should be exactly one region.")
}
if strings.Compare("Candy Land East", regions[0]) != 0 {
t.Fatalf("Expected the region to by \"Candy Land East\", but got %q", regions[0])
}
}