Example #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)
}
Example #2
0
func (s *S) TestFakeAppGetInstances(c *check.C) {
	instance1 := bind.ServiceInstance{Name: "inst1"}
	instance2 := bind.ServiceInstance{Name: "inst2"}
	app := NewFakeApp("sou", "otm", 0)
	app.instances["mysql"] = []bind.ServiceInstance{instance1, instance2}
	instances := app.GetInstances("mysql")
	c.Assert(instances, check.DeepEquals, []bind.ServiceInstance{instance1, instance2})
	instances = app.GetInstances("mongodb")
	c.Assert(instances, check.HasLen, 0)
}