feat: notification service
This commit is contained in:
@@ -32,8 +32,9 @@ type Process struct {
|
||||
logsMu sync.Mutex
|
||||
logs bytes.Buffer
|
||||
|
||||
doneCh chan struct{}
|
||||
waitErr error
|
||||
doneCh chan struct{}
|
||||
waitErr error
|
||||
allowUnexpectedExit bool
|
||||
}
|
||||
|
||||
// StartProcess starts binaryPath with envOverrides and registers cleanup that
|
||||
@@ -82,7 +83,7 @@ func (p *Process) Stop(t testing.TB) {
|
||||
select {
|
||||
case <-p.doneCh:
|
||||
err := p.waitErr
|
||||
if err != nil && !isExpectedProcessExit(err) {
|
||||
if err != nil && !isExpectedProcessExit(err) && !p.allowUnexpectedExit {
|
||||
t.Errorf("%s exited unexpectedly: %v", p.name, err)
|
||||
}
|
||||
return
|
||||
@@ -96,7 +97,7 @@ func (p *Process) Stop(t testing.TB) {
|
||||
select {
|
||||
case <-p.doneCh:
|
||||
err := p.waitErr
|
||||
if err != nil && !isExpectedProcessExit(err) {
|
||||
if err != nil && !isExpectedProcessExit(err) && !p.allowUnexpectedExit {
|
||||
t.Errorf("%s exited unexpectedly: %v", p.name, err)
|
||||
}
|
||||
case <-time.After(defaultStopWait):
|
||||
@@ -105,12 +106,22 @@ func (p *Process) Stop(t testing.TB) {
|
||||
}
|
||||
<-p.doneCh
|
||||
err := p.waitErr
|
||||
if err != nil && !isExpectedProcessExit(err) {
|
||||
if err != nil && !isExpectedProcessExit(err) && !p.allowUnexpectedExit {
|
||||
t.Errorf("%s exited unexpectedly: %v", p.name, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// AllowUnexpectedExit marks a process exit as expected for tests that
|
||||
// deliberately trigger a fatal runtime dependency failure.
|
||||
func (p *Process) AllowUnexpectedExit() {
|
||||
if p == nil {
|
||||
return
|
||||
}
|
||||
|
||||
p.allowUnexpectedExit = true
|
||||
}
|
||||
|
||||
// Logs returns the captured combined stdout/stderr output of the process.
|
||||
func (p *Process) Logs() string {
|
||||
if p == nil {
|
||||
|
||||
Reference in New Issue
Block a user