From 3b36744277e16ade390b4e41d622838c11bf280a Mon Sep 17 00:00:00 2001 From: Ryan Uber Date: Mon, 31 Aug 2015 21:18:04 -0700 Subject: [PATCH] consul/state: testing service registration update --- consul/state/state_store_test.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/consul/state/state_store_test.go b/consul/state/state_store_test.go index b357ce3812..32a8fe6c5c 100644 --- a/consul/state/state_store_test.go +++ b/consul/state/state_store_test.go @@ -310,6 +310,27 @@ func TestStateStore_EnsureService(t *testing.T) { if idx := s.maxIndex("services"); idx != 30 { t.Fatalf("bad index: %d", idx) } + + // Update a service registration + ns1.Address = "1.1.1.2" + if err := s.EnsureService(40, "node1", ns1); err != nil { + t.Fatalf("err: %s", err) + } + + // Retrieve the service again and ensure it matches + idx, out, err = s.NodeServices("node1") + if err != nil { + t.Fatalf("err: %s", err) + } + if idx != 40 { + t.Fatalf("bad index: %d", idx) + } + if out == nil || len(out.Services) == 0 { + t.Fatalf("bad: %#v", out) + } + if svc, ok := out.Services["service1"]; !ok || svc.Address != "1.1.1.2" { + t.Fatalf("bad: %#v", svc) + } } func TestStateStore_DeleteService(t *testing.T) {