예제 #1
0
func (s *S) TestFakeAppBindUnit(c *check.C) {
	var unit provision.Unit
	app := NewFakeApp("sou", "otm", 0)
	err := app.BindUnit(&unit)
	c.Assert(err, check.IsNil)
	c.Assert(app.HasBind(&unit), check.Equals, true)
}
예제 #2
0
func (s *S) TestProvisionUnbindOldUnitsForward(c *check.C) {
	cont, err := s.newContainer(nil, nil)
	c.Assert(err, check.IsNil)
	defer routertest.FakeRouter.RemoveBackend(cont.AppName)
	client, err := docker.NewClient(s.server.URL())
	c.Assert(err, check.IsNil)
	err = client.StartContainer(cont.ID, nil)
	c.Assert(err, check.IsNil)
	app := provisiontest.NewFakeApp(cont.AppName, "python", 0)
	unit := cont.AsUnit(app)
	app.BindUnit(&unit)
	args := changeUnitsPipelineArgs{
		app:         app,
		toRemove:    []container.Container{*cont},
		provisioner: s.p,
	}
	context := action.FWContext{Params: []interface{}{args}, Previous: []container.Container{}}
	result, err := provisionUnbindOldUnits.Forward(context)
	c.Assert(err, check.IsNil)
	resultContainers := result.([]container.Container)
	c.Assert(resultContainers, check.DeepEquals, []container.Container{})
	c.Assert(app.HasBind(&unit), check.Equals, false)
}