Tags: map[string]string{"key": "value"}, } data, err := json.Marshal(msg) Expect(err).NotTo(HaveOccurred()) err = natsClient.Publish("router.register", data) Expect(err).ToNot(HaveOccurred()) Eventually(registry.RegisterCallCount).Should(Equal(2)) Expect(registry.UnregisterCallCount()).To(Equal(0)) err = natsClient.Publish("router.unregister", data) Expect(err).ToNot(HaveOccurred()) Eventually(registry.UnregisterCallCount).Should(Equal(2)) for i := 0; i < registry.UnregisterCallCount(); i++ { uri, endpoint := registry.UnregisterArgsForCall(i) Expect(msg.Uris).To(ContainElement(uri)) Expect(endpoint.ApplicationId).To(Equal(msg.App)) Expect(endpoint.Tags).To(Equal(msg.Tags)) Expect(endpoint.PrivateInstanceId).To(Equal(msg.PrivateInstanceID)) Expect(endpoint.PrivateInstanceIndex).To(Equal(msg.PrivateInstanceIndex)) Expect(endpoint.RouteServiceUrl).To(Equal(msg.RouteServiceURL)) Expect(endpoint.CanonicalAddr()).To(ContainSubstring(msg.Host)) } }) }) })