mirror of
https://github.com/weaveworks/scope.git
synced 2026-05-06 01:08:03 +00:00
Merge pull request #3678 from weaveworks/nodes-omitempty
perf(probe): add 'omitempty' tag to Topology.Nodes
This commit is contained in:
@@ -6,7 +6,6 @@ import (
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"net/url"
|
||||
"reflect"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
@@ -16,6 +15,7 @@ import (
|
||||
"github.com/weaveworks/common/test"
|
||||
"github.com/weaveworks/scope/common/xfer"
|
||||
"github.com/weaveworks/scope/report"
|
||||
"github.com/weaveworks/scope/test/reflect"
|
||||
)
|
||||
|
||||
func dummyServer(t *testing.T, expectedToken, expectedID string, expectedVersion string, expectedReport report.Report, done chan struct{}) *httptest.Server {
|
||||
@@ -70,14 +70,6 @@ func TestAppClientPublish(t *testing.T) {
|
||||
done = make(chan struct{}, 10)
|
||||
)
|
||||
|
||||
// marshalling->unmarshaling is not idempotent due to `json:"omitempty"`
|
||||
// tags, transforming empty slices into nils. So, we make DeepEqual
|
||||
// happy by setting empty `json:"omitempty"` entries to nil
|
||||
rpt.WalkTopologies(func(to *report.Topology) {
|
||||
*to = report.MakeTopology()
|
||||
to.Controls = nil
|
||||
})
|
||||
|
||||
s := dummyServer(t, token, id, version, rpt, done)
|
||||
defer s.Close()
|
||||
|
||||
|
||||
@@ -68,13 +68,6 @@ func TestProbe(t *testing.T) {
|
||||
want := report.MakeReport()
|
||||
node := report.MakeNodeWith("a", map[string]string{"b": "c"})
|
||||
|
||||
// marshalling->unmarshaling is not idempotent due to `json:"omitempty"`
|
||||
// tags, transforming empty slices into nils. So, we make DeepEqual
|
||||
// happy by setting empty `json:"omitempty"` entries to nil
|
||||
node.Metrics = nil
|
||||
want.WalkTopologies(func(t *report.Topology) {
|
||||
t.Controls = nil
|
||||
})
|
||||
want.Endpoint.AddNode(node)
|
||||
|
||||
pub := mockPublisher{make(chan report.Report, 10)}
|
||||
|
||||
@@ -13,7 +13,7 @@ type Topology struct {
|
||||
Tag string `json:"tag,omitempty"`
|
||||
Label string `json:"label,omitempty"`
|
||||
LabelPlural string `json:"label_plural,omitempty"`
|
||||
Nodes Nodes `json:"nodes"`
|
||||
Nodes Nodes `json:"nodes,omitempty" deepequal:"nil==empty"`
|
||||
Controls Controls `json:"controls,omitempty" deepequal:"nil==empty"`
|
||||
MetadataTemplates MetadataTemplates `json:"metadata_templates,omitempty"`
|
||||
MetricTemplates MetricTemplates `json:"metric_templates,omitempty"`
|
||||
|
||||
Reference in New Issue
Block a user