Skip to content

Commit

Permalink
remove hard coded version data in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
skpratt committed Nov 14, 2023
1 parent 8593a9c commit 1760012
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 10 deletions.
2 changes: 1 addition & 1 deletion dependency/catalog_node_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ func TestCatalogNodeQuery_Fetch(t *testing.T) {
},
Meta: map[string]string{
"consul-network-segment": "",
"consul-version": "1.17.0",
},
},
Services: []*CatalogNodeService{
Expand Down Expand Up @@ -157,6 +156,7 @@ func TestCatalogNodeQuery_Fetch(t *testing.T) {
if n := act.(*CatalogNode).Node; n != nil {
n.ID = ""
n.TaggedAddresses = filterAddresses(n.TaggedAddresses)
n.Meta = filterVersionMeta(n.Meta)
}
// delete any version data from ServiceMeta
services := act.(*CatalogNode).Services
Expand Down
2 changes: 1 addition & 1 deletion dependency/catalog_nodes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ func TestCatalogNodesQuery_Fetch(t *testing.T) {
},
Meta: map[string]string{
"consul-network-segment": "",
"consul-version": "1.17.0",
},
},
},
Expand All @@ -115,6 +114,7 @@ func TestCatalogNodesQuery_Fetch(t *testing.T) {
for _, n := range act.([]*Node) {
n.ID = ""
n.TaggedAddresses = filterAddresses(n.TaggedAddresses)
n.Meta = filterVersionMeta(n.Meta)
}
}

Expand Down
4 changes: 2 additions & 2 deletions dependency/catalog_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,6 @@ func TestCatalogServiceQuery_Fetch(t *testing.T) {
},
NodeMeta: map[string]string{
"consul-network-segment": "",
"consul-version": "1.17.0",
},
ServiceID: "consul",
ServiceName: "consul",
Expand All @@ -189,7 +188,6 @@ func TestCatalogServiceQuery_Fetch(t *testing.T) {
},
NodeMeta: map[string]string{
"consul-network-segment": "",
"consul-version": "1.17.0",
},
ServiceID: "service-meta",
ServiceName: "service-meta",
Expand Down Expand Up @@ -225,6 +223,8 @@ func TestCatalogServiceQuery_Fetch(t *testing.T) {
for i := range act_list {
act_list[i].ServiceMeta = filterVersionMeta(
act_list[i].ServiceMeta)
act_list[i].NodeMeta = filterVersionMeta(
act_list[i].NodeMeta)
}

assert.Equal(t, tc.exp, act)
Expand Down
2 changes: 1 addition & 1 deletion dependency/consul_common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func filterVersionMeta(meta map[string]string) map[string]string {
filteredMeta := []string{
"raft_version", "serf_protocol_current",
"serf_protocol_min", "serf_protocol_max", "version",
"non_voter", "read_replica", "grpc_port", "grpc_tls_port",
"non_voter", "read_replica", "grpc_port", "grpc_tls_port", "consul-version",
}
return filter(meta, filteredMeta)
}
Expand Down
8 changes: 3 additions & 5 deletions dependency/health_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,6 @@ func TestHealthConnectServiceQuery_Fetch(t *testing.T) {
Tags: ServiceTags([]string{}),
NodeMeta: map[string]string{
"consul-network-segment": "",
"consul-version": "1.17.0",
},
Weights: api.AgentWeights{
Passing: 1,
Expand Down Expand Up @@ -305,6 +304,7 @@ func TestHealthConnectServiceQuery_Fetch(t *testing.T) {
inst.Checks = nil
inst.NodeTaggedAddresses = nil
inst.ServiceTaggedAddresses = nil
inst.NodeMeta = filterVersionMeta(inst.NodeMeta)

assert.Equal(t, tc.exp, act)
})
Expand All @@ -330,7 +330,6 @@ func TestHealthServiceQuery_Fetch(t *testing.T) {
},
NodeMeta: map[string]string{
"consul-network-segment": "",
"consul-version": "1.17.0",
},
ServiceMeta: map[string]string{},
Address: testConsul.Config.Bind,
Expand Down Expand Up @@ -364,7 +363,6 @@ func TestHealthServiceQuery_Fetch(t *testing.T) {
},
NodeMeta: map[string]string{
"consul-network-segment": "",
"consul-version": "1.17.0",
},
ServiceMeta: map[string]string{},
Address: testConsul.Config.Bind,
Expand Down Expand Up @@ -393,7 +391,6 @@ func TestHealthServiceQuery_Fetch(t *testing.T) {
},
NodeMeta: map[string]string{
"consul-network-segment": "",
"consul-version": "1.17.0",
},
ServiceMeta: map[string]string{
"meta1": "value1",
Expand Down Expand Up @@ -423,7 +420,6 @@ func TestHealthServiceQuery_Fetch(t *testing.T) {
},
NodeMeta: map[string]string{
"consul-network-segment": "",
"consul-version": "1.17.0",
},
ServiceMeta: map[string]string{},
Address: testConsul.Config.Bind,
Expand Down Expand Up @@ -470,6 +466,8 @@ func TestHealthServiceQuery_Fetch(t *testing.T) {
v.ServiceMeta = filterVersionMeta(v.ServiceMeta)
v.NodeTaggedAddresses = filterAddresses(
v.NodeTaggedAddresses)
v.NodeMeta = filterVersionMeta(v.NodeMeta)

}
}

Expand Down

0 comments on commit 1760012

Please sign in to comment.