Пример #1
0
func (s *S) TestSaveUnitsForwardShouldMaintainData(c *gocheck.C) {
	a := app.App{
		Name:     "otherapp",
		Platform: "zend",
		Deploys:  10,
	}
	conn, err := db.Conn()
	c.Assert(err, gocheck.IsNil)
	defer conn.Close()
	err = conn.Apps().Insert(a)
	c.Assert(err, gocheck.IsNil)
	a.Deploys = 0
	defer conn.Apps().Remove(bson.M{"name": a.Name})
	container := container{
		ID:       "id",
		Type:     "python",
		HostAddr: "",
		AppName:  a.Name,
	}
	coll := collection()
	c.Assert(err, gocheck.IsNil)
	coll.Insert(&container)
	context := action.FWContext{Params: []interface{}{&a}}
	_, err = saveUnits.Forward(context)
	c.Assert(err, gocheck.IsNil)
	app, err := app.GetByName(a.Name)
	c.Assert(err, gocheck.IsNil)
	c.Assert(app.Units[0].Name, gocheck.Equals, "id")
	c.Assert(int(app.Deploys), gocheck.Equals, 10)
}