TestTracker_Concurrent ensures the tracker is safe for concurrent use (smoke test under the race detector). It does not verify ordering.
(t *testing.T)
| 125 | // TestTracker_Concurrent ensures the tracker is safe for concurrent use |
| 126 | // (smoke test under the race detector). It does not verify ordering. |
| 127 | func TestTracker_Concurrent(t *testing.T) { |
| 128 | t.Parallel() |
| 129 | |
| 130 | tr := lifecycle.NewTracker() |
| 131 | const n = 100 |
| 132 | done := make(chan struct{}) |
| 133 | for range n { |
| 134 | go func() { |
| 135 | tr.Set(lifecycle.StateStarting) |
| 136 | tr.Set(lifecycle.StateReady) |
| 137 | tr.Fail(lifecycle.StateRestarting, errors.New("boom")) |
| 138 | tr.IncRestarts() |
| 139 | _ = tr.Snapshot() |
| 140 | done <- struct{}{} |
| 141 | }() |
| 142 | } |
| 143 | for range n { |
| 144 | <-done |
| 145 | } |
| 146 | } |
| 147 | |
| 148 | // TestErrors_AreDistinct ensures sentinels do not alias each other, |
| 149 | // guarding against accidental var x = y refactors. |
nothing calls this directly
no test coverage detected