func TestRemoveHook(t *testing.T) { checker := New(time.Millisecond) counter := struct { *sync.Mutex called bool }{ &sync.Mutex{}, false, } checker.AddHook("testHook", func(m map[string]bool) { counter.Lock() counter.called = true counter.Unlock() }) checker.Start() time.Sleep(2 * time.Millisecond) counter.Lock() if !counter.called { t.Error("Counter not called") } counter.called = false counter.Unlock() checker.RemoveHook("testHook") time.Sleep(2 * time.Millisecond) counter.Lock() if counter.called { t.Error("Counter should not be called") } counter.Unlock() checker.Stop() }