Ejemplo n.º 1
0
func (*cmdSuite) TestWhichCMD(c *gc.C) {
	cfgPath, closer := common.TestCfg(c)
	defer closer()

	ctx := common.MockContext(c, common.TenetCfgFlg.LongArg(), cfgPath, "which")
	c.Assert(WhichCMD.Run(ctx), jc.ErrorIsNil)

	// TODO(waigani) test stdout, regex match: ^/home/[^/]*/\.lingo/tenet\.toml
}
Ejemplo n.º 2
0
func (s *cmdSuite) TestRemoveCMD(c *gc.C) {
	cfgPath, closer := common.TestCfg(c)
	defer closer()

	tenetToRemove := common.TenetConfig{Name: "lingo-reviews/license"}
	ctx := common.MockContext(c, common.TenetCfgFlg.LongArg(), cfgPath, "remove", tenetToRemove.Name)

	c.Assert(RemoveCMD.Run(ctx), jc.ErrorIsNil)

	obtained, err := common.ReadConfigFile(cfgPath)
	c.Assert(err, jc.ErrorIsNil)
	for _, t := range obtained.AllTenets() {
		c.Assert(t.Name, gc.Not(gc.Equals), tenetToRemove.Name)
	}
}
Ejemplo n.º 3
0
func (*cmdSuite) TestAddCMD(c *gc.C) {
	fName, closer := common.TestCfg(c)
	defer closer()

	// TODO(waigani) test all defaults and explicitly setting the driver.
	driver := "binary"
	c.Assert(defaultDriver(), gc.Equals, driver)
	newTenet := common.TenetConfig{
		Name:    "waigani/test",
		Driver:  driver,
		Options: make(map[string]interface{}),
	}
	ctx := common.MockContext(c, common.TenetCfgFlg.LongArg(), fName, "add", newTenet.Name)

	orig, err := common.ReadConfigFile(fName)
	c.Assert(err, jc.ErrorIsNil)
	c.Assert(AddCMD.Run(ctx), jc.ErrorIsNil)

	obtained, err := common.ReadConfigFile(fName)
	c.Assert(err, jc.ErrorIsNil)
	expected := append(orig.AllTenets(), newTenet)
	c.Assert(obtained.AllTenets(), gc.DeepEquals, expected)
}
Ejemplo n.º 4
0
func (s *cmdSuite) TestAddCMDNoURLFails(c *gc.C) {
	ctx := common.MockContext(c, "add")

	c.Assert(AddCMD.Run(ctx), jc.ErrorIsNil)
	c.Assert(s.stdErr.String(), gc.Equals, "error: expected 1 argument, got 0\n")
}