You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
go-zero/core/proc/shutdown_test.go

32 lines
517 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++
})
wrapUpListeners.notifyListeners()
called()
assert.Equal(t, 1, val)
called = AddShutdownListener(func() {
val += 2
})
shutdownListeners.notifyListeners()
called()
assert.Equal(t, 3, val)
}