From 125fb96ff102efa9c4488fff2d53ab04fafb2801 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Fri, 9 Mar 2018 17:21:26 -0800 Subject: [PATCH] agent/structs: tests for PartialClone and IsSame for proxy fields --- agent/structs/structs.go | 4 +++- agent/structs/structs_test.go | 6 ++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/agent/structs/structs.go b/agent/structs/structs.go index 4301c7e93d..f8f339a5b0 100644 --- a/agent/structs/structs.go +++ b/agent/structs/structs.go @@ -529,7 +529,9 @@ func (s *NodeService) IsSame(other *NodeService) bool { s.Address != other.Address || s.Port != other.Port || !reflect.DeepEqual(s.Meta, other.Meta) || - s.EnableTagOverride != other.EnableTagOverride { + s.EnableTagOverride != other.EnableTagOverride || + s.Kind != other.Kind || + s.ProxyDestination != other.ProxyDestination { return false } diff --git a/agent/structs/structs_test.go b/agent/structs/structs_test.go index 972146d93e..077636be00 100644 --- a/agent/structs/structs_test.go +++ b/agent/structs/structs_test.go @@ -134,6 +134,7 @@ func testServiceNode() *ServiceNode { NodeMeta: map[string]string{ "tag": "value", }, + ServiceKind: ServiceKindTypical, ServiceID: "service1", ServiceName: "dogs", ServiceTags: []string{"prod", "v1"}, @@ -143,6 +144,7 @@ func testServiceNode() *ServiceNode { "service": "metadata", }, ServiceEnableTagOverride: true, + ServiceProxyDestination: "cats", RaftIndex: RaftIndex{ CreateIndex: 1, ModifyIndex: 2, @@ -275,6 +277,7 @@ func TestStructs_NodeService_IsSame(t *testing.T) { }, Port: 1234, EnableTagOverride: true, + ProxyDestination: "db", } if !ns.IsSame(ns) { t.Fatalf("should be equal to itself") @@ -292,6 +295,7 @@ func TestStructs_NodeService_IsSame(t *testing.T) { "meta2": "value2", "meta1": "value1", }, + ProxyDestination: "db", RaftIndex: RaftIndex{ CreateIndex: 1, ModifyIndex: 2, @@ -325,6 +329,8 @@ func TestStructs_NodeService_IsSame(t *testing.T) { check(func() { other.Port = 9999 }, func() { other.Port = 1234 }) check(func() { other.Meta["meta2"] = "wrongValue" }, func() { other.Meta["meta2"] = "value2" }) check(func() { other.EnableTagOverride = false }, func() { other.EnableTagOverride = true }) + check(func() { other.Kind = ServiceKindConnectProxy }, func() { other.Kind = "" }) + check(func() { other.ProxyDestination = "" }, func() { other.ProxyDestination = "db" }) } func TestStructs_HealthCheck_IsSame(t *testing.T) {