mirror of https://github.com/kubernetes/kops.git
Add tests for aws_utils zones
This commit is contained in:
parent
2972646ae0
commit
3eb92e5fb5
|
|
@ -0,0 +1,56 @@
|
||||||
|
/*
|
||||||
|
Copyright 2016 The Kubernetes Authors.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package awsup
|
||||||
|
|
||||||
|
import (
|
||||||
|
"k8s.io/kops/pkg/apis/kops"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestValidateRegion(t *testing.T) {
|
||||||
|
for _, region := range []string{"us-east-1", "us-east-2", "eu-west-1"} {
|
||||||
|
err := ValidateRegion(region)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("unexpected error validating region %q: %v", region, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, region := range []string{"is-lost-1", "no-road-2", "no-real-3"} {
|
||||||
|
err := ValidateRegion(region)
|
||||||
|
if err == nil {
|
||||||
|
t.Fatalf("expected error validating region %q", region)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestFindRegion(t *testing.T) {
|
||||||
|
for _, zone := range []string{"us-east-1a", "us-east-1b", "us-east-1c", "us-east-2a", "us-east-2b", "us-east-2c"} {
|
||||||
|
c := &kops.Cluster{}
|
||||||
|
c.Spec.Zones = append(c.Spec.Zones, &kops.ClusterZoneSpec{Name: zone})
|
||||||
|
|
||||||
|
region, err := FindRegion(c)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("unexpected error finding region for %q: %v", zone, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
expected := zone[:len(zone)-1]
|
||||||
|
if region != expected {
|
||||||
|
t.Fatalf("unexpected region for zone: %q vs %q", expected, region)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue