Skip to content

Commit

Permalink
Merge pull request #1 from liamg/liamg-setup-build
Browse files Browse the repository at this point in the history
build: setup build
  • Loading branch information
liamg authored Oct 26, 2022
2 parents 1af1dd8 + 03226b9 commit dcbbe60
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
name: tests

on:
pull_request:

jobs:
test:
name: tests
Expand Down
14 changes: 9 additions & 5 deletions watch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,25 @@ 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{})

watchCmd := exec.Command("go", "run", ".", strconv.Itoa(pingCmd.Process.Pid))
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)
}

0 comments on commit dcbbe60

Please sign in to comment.