Пример #1
0
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)
}
Пример #2
0
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")
}
Пример #3
0
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: .*")
}