MCPcopy
hub / github.com/grafana/dskit / TestNilServiceFailureWatcher

Function TestNilServiceFailureWatcher

services/failure_watch_test.go:14–38  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

12)
13
14func TestNilServiceFailureWatcher(t *testing.T) {
15 var w *FailureWatcher
16
17 // prove it doesn't fail, but returns nil channel.
18 require.Nil(t, w.Chan())
19
20 // Ensure WatchService() panics.
21 require.Panics(t, func() {
22 w.WatchService(NewIdleService(nil, nil))
23 })
24
25 // Ensure WatchManager() panics.
26 m, err := NewManager(NewIdleService(nil, nil))
27 require.NoError(t, err)
28 t.Cleanup(func() {
29 require.NoError(t, StopManagerAndAwaitStopped(context.Background(), m))
30 })
31
32 require.Panics(t, func() {
33 w.WatchManager(m)
34 })
35
36 // Closing nil watcher doesn't panic.
37 w.Close()
38}
39
40func TestServiceFailureWatcher(t *testing.T) {
41 w := NewFailureWatcher()

Callers

nothing calls this directly

Calls 7

ChanMethod · 0.95
WatchServiceMethod · 0.95
WatchManagerMethod · 0.95
CloseMethod · 0.95
NewIdleServiceFunction · 0.85
NewManagerFunction · 0.70

Tested by

no test coverage detected