Esempio n. 1
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)
}
Esempio 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)
	}
}