mirror of
https://github.com/weaveworks/scope.git
synced 2026-03-04 18:51:17 +00:00
42 lines
814 B
Go
42 lines
814 B
Go
package controls_test
|
|
|
|
import (
|
|
"reflect"
|
|
"testing"
|
|
|
|
"github.com/weaveworks/scope/common/xfer"
|
|
"github.com/weaveworks/scope/probe/controls"
|
|
"github.com/weaveworks/scope/test"
|
|
)
|
|
|
|
func TestControls(t *testing.T) {
|
|
controls.Register("foo", func(req xfer.Request) xfer.Response {
|
|
return xfer.Response{
|
|
Value: "bar",
|
|
}
|
|
})
|
|
defer controls.Rm("foo")
|
|
|
|
want := xfer.Response{
|
|
Value: "bar",
|
|
}
|
|
have := controls.HandleControlRequest(xfer.Request{
|
|
Control: "foo",
|
|
})
|
|
if !reflect.DeepEqual(want, have) {
|
|
t.Fatal(test.Diff(want, have))
|
|
}
|
|
}
|
|
|
|
func TestControlsNotFound(t *testing.T) {
|
|
want := xfer.Response{
|
|
Error: "Control \"baz\" not recognised",
|
|
}
|
|
have := controls.HandleControlRequest(xfer.Request{
|
|
Control: "baz",
|
|
})
|
|
if !reflect.DeepEqual(want, have) {
|
|
t.Fatal(test.Diff(want, have))
|
|
}
|
|
}
|