Beispiel #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)
}
Beispiel #2
0
func (s *S) TestFakeAppRemoveInstanceNotFound(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)
	err := app.RemoveInstance(
		bind.InstanceApp{
			ServiceName:   "mysql",
			Instance:      instance2,
			ShouldRestart: true,
		}, nil)
	c.Assert(err.Error(), check.Equals, "instance not found")
}