예제 #1
0
func (s *BasicSuite) TestInvalidUpdateService(c *C) {
	svcCfg := client.ServiceConfig{
		Name: "Update",
		Addr: "127.0.0.1:9324",
	}

	if err := Registry.AddService(svcCfg); err != nil {
		c.Fatal(err)
	}

	svc := Registry.GetService("Update")
	if svc == nil {
		c.Fatal(ErrNoService)
	}

	svcCfg.Addr = "127.0.0.1:9425"

	// Make sure we can't add the same service again
	if err := Registry.AddService(svcCfg); err == nil {
		c.Fatal(err)
	}

	// the update should fail, because it would require a new listener
	if err := Registry.UpdateService(svcCfg); err == nil {
		c.Fatal(err)
	}

	// change the addres back, and try to update ClientTimeout
	svcCfg.Addr = "127.0.0.1:9324"
	svcCfg.ClientTimeout = 1234

	// the update should fail, because it would require a new listener
	if err := Registry.UpdateService(svcCfg); err == nil {
		c.Fatal(err)
	}

	if err := Registry.RemoveService("Update"); err != nil {
		c.Fatal(err)
	}
}