func (s *EnvironmentCommandSuite) TestWriteAddsNewline(c *C) { err := cmd.WriteCurrentEnvironment("fubar") c.Assert(err, IsNil) current, err := ioutil.ReadFile(cmd.GetCurrentEnvironmentFilePath()) c.Assert(err, IsNil) c.Assert(string(current), Equals, "fubar\n") }
func (*EnvironmentCommandSuite) TestErrorWritingFile(c *C) { // Can't write a file over a directory. os.MkdirAll(cmd.GetCurrentEnvironmentFilePath(), 0777) err := cmd.WriteCurrentEnvironment("fubar") c.Assert(err, ErrorMatches, "unable to write to the environment file: .*") }