Пример #1
0
func TestStartShouldCallHandlerOnStart(t *testing.T) {
	watchers := []watcher.Watcher{
		mock_watcher.NewChanCloser(1 * time.Millisecond),
	}

	handler := mock_handler.NewHandler()

	runner := NewRunner(handler, watchers, 10)

	runner.Start()

	if handler.CallCount != 1 {
		t.Errorf("Expected 1 call on Start, got [%d] \n", handler.CallCount)
	}
}
Пример #2
0
func TestStartShouldExitOnChanClose(t *testing.T) {
	watchers := []watcher.Watcher{
		time_watcher.NewWatcher(100*time.Millisecond, 5),
		time_watcher.NewWatcher(200*time.Millisecond, 5),
		mock_watcher.NewChanCloser(500 * time.Millisecond),
	}

	handler := mock_handler.NewHandler()

	runner := NewRunner(handler, watchers, 10)

	runner.Start()

	if handler.CallCount == 0 {
		t.Errorf("Expected at least a call [%d] \n", handler.CallCount)
	}

	runner.Stop()
}