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