func (s *maas2StorageSuite) TestGetNotFound(c *gc.C) { storage := s.makeStorage(c, newFakeControllerWithErrors( gomaasapi.NewNoMatchError("wee"), )) _, err := storage.Get("grasshopper.avi") c.Assert(err, jc.Satisfies, errors.IsNotFound) }
func (suite *maas2EnvironSuite) TestBootstrapFailsIfNoNodes(c *gc.C) { suite.setupFakeTools(c) controller := newFakeController() controller.allocateMachineError = gomaasapi.NewNoMatchError("oops") env := suite.makeEnviron(c, controller) err := bootstrap.Bootstrap(envtesting.BootstrapContext(c), env, bootstrap.BootstrapParams{}) // Since there are no nodes, the attempt to allocate one returns a // 409: Conflict. c.Check(err, gc.ErrorMatches, ".*cannot run instances.*") }
func (suite *maas2EnvironSuite) TestControllerInstances(c *gc.C) { controller := newFakeControllerWithErrors(gomaasapi.NewNoMatchError("state")) env := suite.makeEnviron(c, controller) _, err := env.ControllerInstances() c.Assert(err, gc.Equals, environs.ErrNotBootstrapped) tests := [][]instance.Id{{}, {"inst-0"}, {"inst-0", "inst-1"}} for _, expected := range tests { state, err := goyaml.Marshal(&common.BootstrapState{StateInstances: expected}) c.Assert(err, jc.ErrorIsNil) controller.files = []gomaasapi.File{&fakeFile{ name: "agent-prefix-provider-state", contents: state, }} controllerInstances, err := env.ControllerInstances() c.Assert(err, jc.ErrorIsNil) c.Assert(controllerInstances, jc.SameContents, expected) } }
func (suite *maas2EnvironSuite) TestStopInstancesReturnsUnexpectedMAASError(c *gc.C) { suite.checkStopInstancesFails(c, gomaasapi.NewNoMatchError("Something else bad!")) }
func (suite *maas2EnvironSuite) TestControllerInstancesFailsIfNoStateInstances(c *gc.C) { env := suite.makeEnviron(c, newFakeControllerWithErrors(gomaasapi.NewNoMatchError("state"))) _, err := env.ControllerInstances() c.Check(err, gc.Equals, environs.ErrNotBootstrapped) }