(t *testing.T)
| 16 | } |
| 17 | |
| 18 | func TestBasicManagerTransitions(t *testing.T) { |
| 19 | t.Parallel() |
| 20 | |
| 21 | s1 := serviceThatDoesntDoAnything() |
| 22 | s2 := serviceThatDoesntDoAnything() |
| 23 | s3 := serviceThatDoesntDoAnything() |
| 24 | gl := newGatheringManagerListener(t) |
| 25 | |
| 26 | m, err := NewManager(s1, s2, s3) |
| 27 | require.NoError(t, err) |
| 28 | m.AddListener(gl) |
| 29 | |
| 30 | states := m.ServicesByState() |
| 31 | for s, ss := range states { |
| 32 | require.Equal(t, New, s) |
| 33 | require.Len(t, ss, 3) |
| 34 | } |
| 35 | |
| 36 | require.False(t, m.IsHealthy()) |
| 37 | require.False(t, m.IsStopped()) |
| 38 | require.NoError(t, m.StartAsync(context.Background())) |
| 39 | require.NoError(t, m.AwaitHealthy(context.Background())) |
| 40 | require.True(t, m.IsHealthy()) |
| 41 | require.False(t, m.IsStopped()) |
| 42 | |
| 43 | states = m.ServicesByState() |
| 44 | for s, ss := range states { |
| 45 | require.Equal(t, Running, s) |
| 46 | require.Len(t, ss, 3) |
| 47 | } |
| 48 | |
| 49 | m.StopAsync() |
| 50 | require.NoError(t, m.AwaitStopped(context.Background())) |
| 51 | require.False(t, m.IsHealthy()) |
| 52 | require.True(t, m.IsStopped()) |
| 53 | |
| 54 | states = m.ServicesByState() |
| 55 | for s, ss := range states { |
| 56 | require.Equal(t, Terminated, s) |
| 57 | require.Len(t, ss, 3) |
| 58 | } |
| 59 | |
| 60 | require.NoError(t, gl.AwaitTerminated(context.Background())) |
| 61 | require.Equal(t, []string{"healthy", "stopped"}, gl.log) |
| 62 | } |
| 63 | |
| 64 | func TestManagerRequiresServicesToBeInNewState(t *testing.T) { |
| 65 | t.Parallel() |
nothing calls this directly
no test coverage detected