// 2019 Rackspace, Inc. // // 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. // To build this app, run the following command: // CGO_ENABLED=0 GOARCH=amd64 go build -a -installsuffix cgo -o bin/change_dc change_dc.go package findha import ( "strconv" "testing" "github.rackspace.com/gorax/gokeys" ) func TestFindHAPairs(t *testing.T) { cfg, err := gokeys.New(nil) if err != nil { t.Fatalf("gokeys.New:%s", err) } key, err := cfg.Core(false) if err != nil { t.Fatal(err) } r, err := getFailoverDevice(349763, key.Password) if err != nil { t.Fatal(err) } if strconv.Itoa(r.Data.ThisDevice) != "349763" { t.Fatalf("ERROR: device %d does not match 349763", r.Data.ThisDevice) } t.Logf("SUCCESS: found device %d/%d (%s)", r.Data.ThisDevice, r.Data.FailoverDevice, r.Data.Version.ASAVer.ID) } func TestGetDeviceList(t *testing.T) { cfg, err := gokeys.New(nil) if err != nil { t.Fatalf("gokeys.New:%s", err) } key, err := cfg.Core(false) if err != nil { t.Fatal(err) } r, err := getDeviceList([]string{"IAD2-MG-09"}, key.Password, "iad2") if err != nil { t.Fatal(err) } if len(r) == 0 { t.Fatalf("ERROR: no devices returned") } t.Logf("SUCCESS: found %d devices for move-group", len(r)) }