diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7888c6e..5c027e9 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,8 +1,6 @@ name: tests - on: pull_request: - jobs: test: name: tests diff --git a/watch_test.go b/watch_test.go index 26f5c98..78713f3 100644 --- a/watch_test.go +++ b/watch_test.go @@ -19,11 +19,11 @@ func Test_Watch(t *testing.T) { require.Equal(t, 0, os.Getuid(), "test must be run as root") pingBuffer := bytes.NewBuffer([]byte{}) - pingCmd := exec.Command("ping", "8.8.8.8") + pingCmd := exec.Command("ping", "127.0.0.1") pingCmd.Stdout = pingBuffer require.NoError(t, pingCmd.Start()) - time.Sleep(time.Second * 1) + time.Sleep(time.Second) watchBuffer := bytes.NewBuffer([]byte{}) @@ -31,9 +31,13 @@ func Test_Watch(t *testing.T) { watchCmd.Stdout = watchBuffer require.NoError(t, watchCmd.Start()) - _ = pingCmd.Wait() + time.Sleep(5 * time.Second) + require.NoError(t, pingCmd.Process.Kill()) + require.NoError(t, pingCmd.Process.Release()) + _ = watchCmd.Wait() - assert.True(t, strings.HasSuffix(pingBuffer.String(), watchBuffer.String())) - assert.Greater(t, len(watchBuffer.String()), 0) + watchOutput := watchBuffer.String() + assert.True(t, strings.HasSuffix(pingBuffer.String(), watchOutput)) + assert.Greater(t, len(watchOutput), 0) }