(t *testing.T, newService func(t *testing.T) serviceWithStopped)
| 50 | } |
| 51 | |
| 52 | func testService(t *testing.T, newService func(t *testing.T) serviceWithStopped) { |
| 53 | t.Helper() |
| 54 | |
| 55 | ctx := context.Background() |
| 56 | |
| 57 | type testBundle struct{} |
| 58 | |
| 59 | setup := func(t *testing.T) (serviceWithStopped, *testBundle) { |
| 60 | t.Helper() |
| 61 | |
| 62 | return newService(t), &testBundle{} |
| 63 | } |
| 64 | |
| 65 | t.Run("StopAndStart", func(t *testing.T) { |
| 66 | t.Parallel() |
| 67 | |
| 68 | service, _ := setup(t) |
| 69 | |
| 70 | require.NoError(t, service.Start(ctx)) |
| 71 | service.Stop() |
| 72 | }) |
| 73 | |
| 74 | t.Run("DoubleStop", func(t *testing.T) { |
| 75 | t.Parallel() |
| 76 | |
| 77 | service, _ := setup(t) |
| 78 | |
| 79 | require.NoError(t, service.Start(ctx)) |
| 80 | service.Stop() |
| 81 | service.Stop() |
| 82 | }) |
| 83 | |
| 84 | t.Run("StopWithoutStart", func(t *testing.T) { |
| 85 | t.Parallel() |
| 86 | |
| 87 | service, _ := setup(t) |
| 88 | |
| 89 | service.Stop() |
| 90 | }) |
| 91 | |
| 92 | t.Run("StartedChannel", func(t *testing.T) { |
| 93 | t.Parallel() |
| 94 | |
| 95 | service, _ := setup(t) |
| 96 | |
| 97 | require.NoError(t, service.Start(ctx)) |
| 98 | t.Cleanup(service.Stop) |
| 99 | |
| 100 | riversharedtest.WaitOrTimeout(t, service.Started()) |
| 101 | }) |
| 102 | |
| 103 | t.Run("StoppedChannel", func(t *testing.T) { |
| 104 | t.Parallel() |
| 105 | |
| 106 | service, _ := setup(t) |
| 107 | |
| 108 | require.NoError(t, service.Start(ctx)) |
| 109 |
no test coverage detected
searching dependent graphs…