func (s *filesSuite) TestWriteControllerRemovesEnvironmentFile(c *gc.C) { err := modelcmd.WriteCurrentModel("fubar") c.Assert(err, jc.ErrorIsNil) err = modelcmd.WriteCurrentController("baz") c.Assert(err, jc.ErrorIsNil) c.Assert(modelcmd.GetCurrentModelFilePath(), jc.DoesNotExist) }
func (s *filesSuite) TestWriteEnvironmentAddsNewline(c *gc.C) { err := modelcmd.WriteCurrentModel("fubar") c.Assert(err, jc.ErrorIsNil) current, err := ioutil.ReadFile(modelcmd.GetCurrentModelFilePath()) c.Assert(err, jc.ErrorIsNil) c.Assert(string(current), gc.Equals, "fubar\n") }
func (*filesSuite) TestErrorWritingCurrentModel(c *gc.C) { // Can't write a file over a directory. os.MkdirAll(modelcmd.GetCurrentModelFilePath(), 0777) err := modelcmd.WriteCurrentModel("fubar") c.Assert(err, gc.ErrorMatches, "unable to write to the model file: .*") }