mirror of
https://github.com/weaveworks/scope.git
synced 2026-07-28 09:41:57 +00:00
Review Feedback
Squash of: - including children in topologies_test.go - report.Node.Prune should prune children also - rewrote ShortLivedInternetConnections test to express its intent - adding tests for detail Summary rendering
This commit is contained in:
@@ -86,26 +86,21 @@ func (m LatestMap) Merge(other LatestMap) LatestMap {
|
||||
|
||||
// Lookup the value for the given key.
|
||||
func (m LatestMap) Lookup(key string) (string, bool) {
|
||||
if m.Map == nil {
|
||||
return "", false
|
||||
}
|
||||
value, ok := m.Map.Lookup(key)
|
||||
if !ok {
|
||||
return "", false
|
||||
}
|
||||
return value.(LatestEntry).Value, true
|
||||
v, _, ok := m.LookupEntry(key)
|
||||
return v, ok
|
||||
}
|
||||
|
||||
// LookupEntry returns the raw entry for the given key.
|
||||
func (m LatestMap) LookupEntry(key string) (LatestEntry, bool) {
|
||||
func (m LatestMap) LookupEntry(key string) (string, time.Time, bool) {
|
||||
if m.Map == nil {
|
||||
return LatestEntry{}, false
|
||||
return "", time.Time{}, false
|
||||
}
|
||||
value, ok := m.Map.Lookup(key)
|
||||
if !ok {
|
||||
return LatestEntry{}, false
|
||||
return "", time.Time{}, false
|
||||
}
|
||||
return value.(LatestEntry), true
|
||||
e := value.(LatestEntry)
|
||||
return e.Value, e.Timestamp, true
|
||||
}
|
||||
|
||||
// Set the value for the given key.
|
||||
|
||||
@@ -33,11 +33,11 @@ func TestLatestMapLookupEntry(t *testing.T) {
|
||||
now := time.Now()
|
||||
entry := LatestEntry{Timestamp: now, Value: "Bar"}
|
||||
have := EmptyLatestMap.Set("foo", entry.Timestamp, entry.Value)
|
||||
if got, ok := have.LookupEntry("foo"); !ok || got != entry {
|
||||
t.Errorf("got: %#v != expected %#v", got, entry)
|
||||
if got, timestamp, ok := have.LookupEntry("foo"); !ok || got != entry.Value || !timestamp.Equal(entry.Timestamp) {
|
||||
t.Errorf("got: %#v %v != expected %#v", got, timestamp, entry)
|
||||
}
|
||||
if got, ok := have.LookupEntry("not found"); ok {
|
||||
t.Errorf("found unexpected entry for %q: %#v", "not found", got)
|
||||
if got, timestamp, ok := have.LookupEntry("not found"); ok {
|
||||
t.Errorf("found unexpected entry for %q: %#v %v", "not found", got, timestamp)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -219,8 +219,13 @@ func (n Node) Merge(other Node) Node {
|
||||
// for rendering nodes and edges stripped away. Specifically, that means
|
||||
// cutting out parts of the Node.
|
||||
func (n Node) Prune() Node {
|
||||
prunedChildren := MakeNodeSet()
|
||||
n.Children.ForEach(func(child Node) {
|
||||
prunedChildren = prunedChildren.Add(child.Prune())
|
||||
})
|
||||
return MakeNode().
|
||||
WithID(n.ID).
|
||||
WithTopology(n.Topology).
|
||||
WithAdjacent(n.Adjacency.Copy()...)
|
||||
WithAdjacent(n.Adjacency.Copy()...).
|
||||
WithChildren(prunedChildren)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user