本文整理汇总了Golang中github.com/weaveworks/scope/render.Filter类的典型用法代码示例。如果您正苦于以下问题:Golang Filter类的具体用法?Golang Filter怎么用?Golang Filter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Filter类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: TestFilterUnconnectedPesudoNodes
func TestFilterUnconnectedPesudoNodes(t *testing.T) {
// Test pseudo nodes that are made unconnected by filtering
// are also removed.
{
nodes := render.RenderableNodes{
"foo": {ID: "foo", Node: report.MakeNode().WithAdjacent("bar")},
"bar": {ID: "bar", Node: report.MakeNode().WithAdjacent("baz")},
"baz": {ID: "baz", Node: report.MakeNode(), Pseudo: true},
}
renderer := render.Filter{
FilterFunc: func(node render.RenderableNode) bool {
return true
},
Renderer: mockRenderer{RenderableNodes: nodes},
}
want := nodes.Prune()
have := renderer.Render(report.MakeReport()).Prune()
if !reflect.DeepEqual(want, have) {
t.Error(test.Diff(want, have))
}
}
{
renderer := render.Filter{
FilterFunc: func(node render.RenderableNode) bool {
return node.ID != "bar"
},
Renderer: mockRenderer{RenderableNodes: render.RenderableNodes{
"foo": {ID: "foo", Node: report.MakeNode().WithAdjacent("bar")},
"bar": {ID: "bar", Node: report.MakeNode().WithAdjacent("baz")},
"baz": {ID: "baz", Node: report.MakeNode(), Pseudo: true},
}},
}
want := render.RenderableNodes{
"foo": {ID: "foo", Node: report.MakeNode()},
}
have := renderer.Render(report.MakeReport()).Prune()
if !reflect.DeepEqual(want, have) {
t.Error(test.Diff(want, have))
}
}
{
renderer := render.Filter{
FilterFunc: func(node render.RenderableNode) bool {
return node.ID != "bar"
},
Renderer: mockRenderer{RenderableNodes: render.RenderableNodes{
"foo": {ID: "foo", Node: report.MakeNode()},
"bar": {ID: "bar", Node: report.MakeNode().WithAdjacent("foo")},
"baz": {ID: "baz", Node: report.MakeNode().WithAdjacent("bar"), Pseudo: true},
}},
}
want := render.RenderableNodes{
"foo": {ID: "foo", Node: report.MakeNode()},
}
have := renderer.Render(report.MakeReport()).Prune()
if !reflect.DeepEqual(want, have) {
t.Error(test.Diff(want, have))
}
}
}
示例2: TestFilterRender2
func TestFilterRender2(t *testing.T) {
// Test adjacencies are removed for filtered nodes.
renderer := render.Filter{
FilterFunc: func(node render.RenderableNode) bool {
return node.ID != "bar"
},
Renderer: mockRenderer{RenderableNodes: render.RenderableNodes{
"foo": {ID: "foo", Node: report.MakeNode().WithAdjacent("bar")},
"bar": {ID: "bar", Node: report.MakeNode().WithAdjacent("foo")},
"baz": {ID: "baz", Node: report.MakeNode()},
}},
}
want := render.RenderableNodes{
"foo": {ID: "foo", Node: report.MakeNode()},
"baz": {ID: "baz", Node: report.MakeNode()},
}
have := renderer.Render(report.MakeReport()).Prune()
if !reflect.DeepEqual(want, have) {
t.Error(test.Diff(want, have))
}
}