func assertEnvironDestroyed(c *gc.C, env environs.Environ, store configstore.Storage) { _, err := store.ReadInfo(env.Name()) c.Assert(err, jc.Satisfies, errors.IsNotFound) _, err = env.Instances([]instance.Id{"invalid"}) c.Assert(err, gc.ErrorMatches, "environment has been destroyed") }
// StateInfo is a reusable implementation of Environ.StateInfo, available to // providers that also use the other functionality from this file. func StateInfo(env environs.Environ) (*state.Info, *api.Info, error) { st, err := bootstrap.LoadState(env.Storage()) if err != nil { return nil, nil, err } config := env.Config() if _, hasCert := config.CACert(); !hasCert { return nil, nil, fmt.Errorf("no CA certificate in environment configuration") } // Wait for the addresses of at least one of the instances to become available. logger.Debugf("waiting for addresses of state server instances %v", st.StateInstances) var addresses []string for a := LongAttempt.Start(); len(addresses) == 0 && a.Next(); { insts, err := env.Instances(st.StateInstances) if err != nil && err != environs.ErrPartialInstances { logger.Debugf("error getting state instances: %v", err.Error()) return nil, nil, err } addresses = getAddresses(insts) } if len(addresses) == 0 { return nil, nil, fmt.Errorf("timed out waiting for addresses from %v", st.StateInstances) } stateInfo, apiInfo := getStateInfo(config, addresses) return stateInfo, apiInfo, nil }