mirror of
https://github.com/zeromicro/go-zero.git
synced 2025-02-03 00:38:40 +08:00
696da4efee
* chore: add more tests * chore: add more tests * chore: add more tests * chore: add more tests * chore: add more tests * chore: add more tests
32 lines
467 B
Go
32 lines
467 B
Go
//go:build linux || darwin
|
|
// +build linux darwin
|
|
|
|
package proc
|
|
|
|
import (
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestShutdown(t *testing.T) {
|
|
SetTimeToForceQuit(time.Hour)
|
|
assert.Equal(t, time.Hour, delayTimeBeforeForceQuit)
|
|
|
|
var val int
|
|
called := AddWrapUpListener(func() {
|
|
val++
|
|
})
|
|
WrapUp()
|
|
called()
|
|
assert.Equal(t, 1, val)
|
|
|
|
called = AddShutdownListener(func() {
|
|
val += 2
|
|
})
|
|
Shutdown()
|
|
called()
|
|
assert.Equal(t, 3, val)
|
|
}
|