Exemplo n.º 1
0
func (s *S) TestFakeAppRemoveInstance(c *check.C) {
	instance1 := bind.ServiceInstance{Name: "inst1"}
	instance2 := bind.ServiceInstance{Name: "inst2"}
	app := NewFakeApp("sou", "otm", 0)
	app.AddInstance(
		bind.InstanceApp{
			ServiceName:   "mysql",
			Instance:      instance1,
			ShouldRestart: true,
		}, nil)
	app.AddInstance(
		bind.InstanceApp{
			ServiceName:   "mongodb",
			Instance:      instance2,
			ShouldRestart: false,
		}, nil)
	err := app.RemoveInstance(
		bind.InstanceApp{
			ServiceName:   "mysql",
			Instance:      instance1,
			ShouldRestart: true,
		}, nil)
	c.Assert(err, check.IsNil)
	instances := app.GetInstances("mysql")
	c.Assert(instances, check.HasLen, 0)
	instances = app.GetInstances("mongodb")
	c.Assert(instances, check.HasLen, 1)
}
Exemplo n.º 2
0
func (s *S) TestFakeAppRemoveInstanceServiceNotFound(c *check.C) {
	instance := bind.ServiceInstance{Name: "inst1"}
	app := NewFakeApp("sou", "otm", 0)
	err := app.RemoveInstance(
		bind.InstanceApp{
			ServiceName:   "mysql",
			Instance:      instance,
			ShouldRestart: true,
		}, nil)
	c.Assert(err.Error(), check.Equals, "instance not found")
}