2019-08-06 18:53:14 +02:00
|
|
|
package monitor
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestMonitor(t *testing.T) {
|
|
|
|
// create new monitor
|
|
|
|
m := NewMonitor()
|
|
|
|
|
2019-08-06 20:02:57 +02:00
|
|
|
if err := m.Run(); err != nil {
|
|
|
|
t.Fatalf("failed to stop monitor: %v", err)
|
|
|
|
}
|
|
|
|
|
2019-08-06 18:53:14 +02:00
|
|
|
services := []string{"foo", "bar", "baz"}
|
|
|
|
|
|
|
|
for _, service := range services {
|
|
|
|
_, err := m.Status(service)
|
2019-08-06 19:05:05 +02:00
|
|
|
if err == nil {
|
2019-08-06 18:53:14 +02:00
|
|
|
t.Fatal("expected status error for unknown service")
|
|
|
|
}
|
2019-08-06 19:05:05 +02: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 18:53:14 +02:00
|
|
|
}
|
2019-08-06 19:05:05 +02:00
|
|
|
|
|
|
|
// stop monitor
|
2019-08-06 20:02:57 +02:00
|
|
|
if err := m.Stop(); err != nil {
|
|
|
|
t.Fatalf("failed to stop monitor: %v", err)
|
|
|
|
}
|
2019-08-06 18:53:14 +02:00
|
|
|
}
|