2019-08-06 17:53:14 +01:00
|
|
|
package monitor
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestMonitor(t *testing.T) {
|
|
|
|
// create new monitor
|
|
|
|
m := NewMonitor()
|
|
|
|
|
2019-08-06 19:02:57 +01:00
|
|
|
if err := m.Run(); err != nil {
|
|
|
|
t.Fatalf("failed to stop monitor: %v", err)
|
|
|
|
}
|
|
|
|
|
2019-08-06 17:53:14 +01:00
|
|
|
services := []string{"foo", "bar", "baz"}
|
|
|
|
|
|
|
|
for _, service := range services {
|
|
|
|
_, err := m.Status(service)
|
2019-08-06 18:05:05 +01:00
|
|
|
if err == nil {
|
2019-08-06 17:53:14 +01:00
|
|
|
t.Fatal("expected status error for unknown service")
|
|
|
|
}
|
2019-08-06 18:05:05 +01:00
|
|
|
|
|
|
|
if err := m.Watch(service); err == nil {
|
|
|
|
t.Fatal("expected watch error for unknown service")
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO:
|
|
|
|
// 1. start a service
|
|
|
|
// 2. watch service
|
|
|
|
// 3. get service status
|
2019-08-06 17:53:14 +01:00
|
|
|
}
|
2019-08-06 18:05:05 +01:00
|
|
|
|
|
|
|
// stop monitor
|
2019-08-06 19:02:57 +01:00
|
|
|
if err := m.Stop(); err != nil {
|
|
|
|
t.Fatalf("failed to stop monitor: %v", err)
|
|
|
|
}
|
2019-08-06 17:53:14 +01:00
|
|
|
}
|