示例#1
0
func (s *FileVarSuite) TestReadNotStdin(c *gc.C) {
	var config cmd.FileVar
	config.Set("-")
	_, err := config.Read(s.ctx)

	c.Check(err, jc.Satisfies, os.IsNotExist)
}
示例#2
0
func (s *FileVarSuite) TestReadStdin(c *gc.C) {
	s.ctx.Stdin = bytes.NewBufferString("abc")

	var config cmd.FileVar
	config.SetStdin()
	config.Set("-")
	file, err := config.Read(s.ctx)
	c.Assert(err, gc.IsNil)
	c.Assert(string(file), gc.Equals, "abc")
}
示例#3
0
func (s *FileVarSuite) TestReadTilde(c *gc.C) {
	path := filepath.Join(utils.Home(), "config.yaml")
	err := ioutil.WriteFile(path, []byte("abc"), 0644)
	c.Assert(err, gc.IsNil)

	var config cmd.FileVar
	config.Set("~/config.yaml")
	file, err := config.Read(s.ctx)
	c.Assert(err, gc.IsNil)
	c.Assert(string(file), gc.Equals, "abc")
}