Beispiel #1
0
func (s *filesSuite) TestWriteControllerAddsNewline(c *gc.C) {
	err := modelcmd.WriteCurrentController("fubar")
	c.Assert(err, jc.ErrorIsNil)
	current, err := ioutil.ReadFile(modelcmd.GetCurrentControllerFilePath())
	c.Assert(err, jc.ErrorIsNil)
	c.Assert(string(current), gc.Equals, "fubar\n")
}
Beispiel #2
0
func (s *filesSuite) TestWriteEnvironmentRemovesControllerFile(c *gc.C) {
	err := modelcmd.WriteCurrentController("baz")
	c.Assert(err, jc.ErrorIsNil)
	err = modelcmd.WriteCurrentModel("fubar")
	c.Assert(err, jc.ErrorIsNil)
	c.Assert(modelcmd.GetCurrentControllerFilePath(), jc.DoesNotExist)
}
Beispiel #3
0
func (*filesSuite) TestErrorWritingCurrentController(c *gc.C) {
	// Can't write a file over a directory.
	os.MkdirAll(modelcmd.GetCurrentControllerFilePath(), 0777)
	err := modelcmd.WriteCurrentController("fubar")
	c.Assert(err, gc.ErrorMatches, "unable to write to the controller file: .*")
}