mirror of
https://github.com/status-im/consul.git
synced 2025-02-27 21:00:44 +00:00
agent/structs: tests for PartialClone and IsSame for proxy fields
This commit is contained in:
parent
9781cb1ace
commit
125fb96ff1
@ -529,7 +529,9 @@ func (s *NodeService) IsSame(other *NodeService) bool {
|
|||||||
s.Address != other.Address ||
|
s.Address != other.Address ||
|
||||||
s.Port != other.Port ||
|
s.Port != other.Port ||
|
||||||
!reflect.DeepEqual(s.Meta, other.Meta) ||
|
!reflect.DeepEqual(s.Meta, other.Meta) ||
|
||||||
s.EnableTagOverride != other.EnableTagOverride {
|
s.EnableTagOverride != other.EnableTagOverride ||
|
||||||
|
s.Kind != other.Kind ||
|
||||||
|
s.ProxyDestination != other.ProxyDestination {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -134,6 +134,7 @@ func testServiceNode() *ServiceNode {
|
|||||||
NodeMeta: map[string]string{
|
NodeMeta: map[string]string{
|
||||||
"tag": "value",
|
"tag": "value",
|
||||||
},
|
},
|
||||||
|
ServiceKind: ServiceKindTypical,
|
||||||
ServiceID: "service1",
|
ServiceID: "service1",
|
||||||
ServiceName: "dogs",
|
ServiceName: "dogs",
|
||||||
ServiceTags: []string{"prod", "v1"},
|
ServiceTags: []string{"prod", "v1"},
|
||||||
@ -143,6 +144,7 @@ func testServiceNode() *ServiceNode {
|
|||||||
"service": "metadata",
|
"service": "metadata",
|
||||||
},
|
},
|
||||||
ServiceEnableTagOverride: true,
|
ServiceEnableTagOverride: true,
|
||||||
|
ServiceProxyDestination: "cats",
|
||||||
RaftIndex: RaftIndex{
|
RaftIndex: RaftIndex{
|
||||||
CreateIndex: 1,
|
CreateIndex: 1,
|
||||||
ModifyIndex: 2,
|
ModifyIndex: 2,
|
||||||
@ -275,6 +277,7 @@ func TestStructs_NodeService_IsSame(t *testing.T) {
|
|||||||
},
|
},
|
||||||
Port: 1234,
|
Port: 1234,
|
||||||
EnableTagOverride: true,
|
EnableTagOverride: true,
|
||||||
|
ProxyDestination: "db",
|
||||||
}
|
}
|
||||||
if !ns.IsSame(ns) {
|
if !ns.IsSame(ns) {
|
||||||
t.Fatalf("should be equal to itself")
|
t.Fatalf("should be equal to itself")
|
||||||
@ -292,6 +295,7 @@ func TestStructs_NodeService_IsSame(t *testing.T) {
|
|||||||
"meta2": "value2",
|
"meta2": "value2",
|
||||||
"meta1": "value1",
|
"meta1": "value1",
|
||||||
},
|
},
|
||||||
|
ProxyDestination: "db",
|
||||||
RaftIndex: RaftIndex{
|
RaftIndex: RaftIndex{
|
||||||
CreateIndex: 1,
|
CreateIndex: 1,
|
||||||
ModifyIndex: 2,
|
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.Port = 9999 }, func() { other.Port = 1234 })
|
||||||
check(func() { other.Meta["meta2"] = "wrongValue" }, func() { other.Meta["meta2"] = "value2" })
|
check(func() { other.Meta["meta2"] = "wrongValue" }, func() { other.Meta["meta2"] = "value2" })
|
||||||
check(func() { other.EnableTagOverride = false }, func() { other.EnableTagOverride = true })
|
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) {
|
func TestStructs_HealthCheck_IsSame(t *testing.T) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user