shutdown_test.go 517 B

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