(ctx context.Context)
| 104 | } |
| 105 | |
| 106 | func (m *mockService) Start(ctx context.Context) error { |
| 107 | select { |
| 108 | case <-ctx.Done(): |
| 109 | return fmt.Errorf("context canceled: %w", ctx.Err()) |
| 110 | default: |
| 111 | } |
| 112 | |
| 113 | if m.startDelay > 0 { |
| 114 | timer := time.NewTimer(m.startDelay) |
| 115 | select { |
| 116 | case <-ctx.Done(): |
| 117 | timer.Stop() |
| 118 | return fmt.Errorf("context canceled: %w", ctx.Err()) |
| 119 | case <-timer.C: |
| 120 | // Continue after delay |
| 121 | } |
| 122 | } |
| 123 | |
| 124 | if m.startError != nil { |
| 125 | m.started = false |
| 126 | return m.startError |
| 127 | } |
| 128 | |
| 129 | m.started = true |
| 130 | return nil |
| 131 | } |
| 132 | |
| 133 | func (m *mockService) String() string { |
| 134 | return m.name |