shutdown_test.go 466 B

12345678910111213141516171819202122232425262728
  1. package proc
  2. import (
  3. "testing"
  4. "time"
  5. "github.com/stretchr/testify/assert"
  6. )
  7. func TestShutdown(t *testing.T) {
  8. SetTimeToForceQuit(time.Hour)
  9. assert.Equal(t, time.Hour, delayTimeBeforeForceQuit)
  10. var val int
  11. called := AddWrapUpListener(func() {
  12. val++
  13. })
  14. wrapUpListeners.notifyListeners()
  15. called()
  16. assert.Equal(t, 1, val)
  17. called = AddShutdownListener(func() {
  18. val += 2
  19. })
  20. shutdownListeners.notifyListeners()
  21. called()
  22. assert.Equal(t, 3, val)
  23. }