region_test.go
48 lines1
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
package platform
import "testing"
func TestAllRegionsCount(t *testing.T) {
regions := AllRegions()
if len(regions) != 9 {
t.Errorf("AllRegions() returned %d regions, want 9", len(regions))
}
}
func TestAllRegionsContainsAll(t *testing.T) {
expected := []Region{NYC, SFO, TOR, LON, AMS, FRA, SGP, SYD, BLR}
regions := AllRegions()
if len(regions) != len(expected) {
t.Fatalf("AllRegions() length = %d, want %d", len(regions), len(expected))
}
for i, r := range expected {
if regions[i] != r {
t.Errorf("AllRegions()[%d] = %q, want %q", i, regions[i], r)
}
}
}
func TestRegionStringValues(t *testing.T) {
tests := []struct {
region Region
want string
}{
{NYC, "nyc"},
{SFO, "sfo"},
{TOR, "tor"},
{LON, "lon"},
{AMS, "ams"},
{FRA, "fra"},
{SGP, "sgp"},
{SYD, "syd"},
{BLR, "blr"},
}
for _, tt := range tests {
if string(tt.region) != tt.want {
t.Errorf("Region %v = %q, want %q", tt.region, string(tt.region), tt.want)
}
}
}