Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

manager_test.go 855B

123456789101112131415161718192021222324252627282930313233
  1. package process
  2. import (
  3. "os/exec"
  4. "testing"
  5. "github.com/stretchr/testify/assert"
  6. )
  7. func TestManager_Add(t *testing.T) {
  8. pm := Manager{Processes: make(map[int64]*Process)}
  9. pid := pm.Add("foo", exec.Command("foo"))
  10. assert.Equal(t, int64(1), pid, "expected to get pid 1 got %d", pid)
  11. pid = pm.Add("bar", exec.Command("bar"))
  12. assert.Equal(t, int64(2), pid, "expected to get pid 2 got %d", pid)
  13. }
  14. func TestManager_Remove(t *testing.T) {
  15. pm := Manager{Processes: make(map[int64]*Process)}
  16. pid1 := pm.Add("foo", exec.Command("foo"))
  17. assert.Equal(t, int64(1), pid1, "expected to get pid 1 got %d", pid1)
  18. pid2 := pm.Add("bar", exec.Command("bar"))
  19. assert.Equal(t, int64(2), pid2, "expected to get pid 2 got %d", pid2)
  20. pm.Remove(pid2)
  21. _, exists := pm.Processes[pid2]
  22. assert.False(t, exists, "PID %d is in the list but shouldn't", pid2)
  23. }