mirror of
https://github.com/zeromicro/go-zero.git
synced 2025-01-23 09:00:20 +08:00
add more tests for proc (#439)
This commit is contained in:
parent
b88ba14597
commit
d04b54243d
28
core/proc/shutdown_test.go
Normal file
28
core/proc/shutdown_test.go
Normal file
@ -0,0 +1,28 @@
|
||||
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)
|
||||
}
|
8
core/proc/stopper_test.go
Normal file
8
core/proc/stopper_test.go
Normal file
@ -0,0 +1,8 @@
|
||||
package proc
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestNopStopper(t *testing.T) {
|
||||
// no panic
|
||||
noopStopper.Stop()
|
||||
}
|
Loading…
Reference in New Issue
Block a user