func TestMonitorInvalidDesc(t *testing.T) { auth, err := aws.EnvAuth() if err != nil { panic(err) } s := ec2.New(auth, aws.EUWest) d, err := NewEC2InstanceDesc(s, "adfg", "asdf", "asd") if err != nil { t.Fatal(err) } m, err := d.StartChangeMonitor(time.Second * 1) if err != nil { t.Fatal(err) } quit := make(chan bool) go func() { for trace := range m.TraceChan { if trace.err == nil { t.Error("Monitor didn't fail on invalid arguments") } // only run once fmt.Println(trace.err.Error()) quit <- true } }() // wait for the error to return after a tick <-quit // exit the monitor m.Quit() }
// Make sure that no empty arguments are accepted. // TODO: make sure that the parameters // do not contains wild-cards '*' func TestEmptyDesc(t *testing.T) { auth, err := aws.EnvAuth() if err != nil { panic(err) } s := ec2.New(auth, aws.EUWest) _, err = NewEC2InstanceDesc(s, "", "", "") if err == nil { t.Fatal("Blank arguments accepted") } }
// Make sure that we fail gracefully // on invalid arguments func TestInvalidDesc(t *testing.T) { auth, err := aws.EnvAuth() if err != nil { panic(err) } s := ec2.New(auth, aws.EUWest) d, err := NewEC2InstanceDesc(s, "adfg", "asdf", "asd") if err != nil { t.Fatal(err) } _, err = d.GetHorizon(time.Now().AddDate(0, 0, -7)) if err == nil { t.Fatal("invalid parameters acepted") } }
func init() { runtime.GOMAXPROCS(4) auth, err := aws.EnvAuth() if err != nil { panic(err) } s := ec2.New(auth, aws.EUWest) desc, err = NewEC2InstanceDesc(s, "m1.medium", "Linux/UNIX", "eu-west-1b") if err != nil { panic(err) } }