Roni Riska | fc77ebb | 2019-09-26 08:20:44 +0300 | [diff] [blame] | 1 | package main |
| 2 | |
| 3 | import ( |
| 4 | "testing" |
| 5 | |
| 6 | "github.com/stretchr/testify/assert" |
| 7 | ) |
| 8 | |
| 9 | func TestProcessRunning(t *testing.T) { |
| 10 | r := makeRunner("echo", "a") |
| 11 | ch := make(chan error) |
| 12 | r.run(ch) |
| 13 | err := <-ch |
| 14 | assert.Nil(t, err) |
| 15 | } |
| 16 | |
| 17 | func TestProcessKill(t *testing.T) { |
| 18 | r := makeRunner("sleep", "20") |
| 19 | ch := make(chan error) |
| 20 | r.run(ch) |
| 21 | assert.Nil(t, r.kill()) |
| 22 | <-ch // wait and seee that kills is actually done |
| 23 | } |
| 24 | |
| 25 | func TestProcessRunningFails(t *testing.T) { |
| 26 | r := makeRunner("foobarbaz") |
| 27 | ch := make(chan error) |
| 28 | r.run(ch) |
| 29 | err := <-ch |
| 30 | assert.NotNil(t, err) |
| 31 | } |