Last active
February 13, 2019 18:46
-
-
Save williammartin/8e510b3a1859564de44e799b4fbd231b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package matcher_test | |
import ( | |
"os/exec" | |
"time" | |
. "github.com/onsi/ginkgo" | |
. "github.com/onsi/gomega" | |
"golang.org/x/sys/unix" | |
) | |
var _ = Describe("Pid Matcher Example", func() { | |
When("there is a process running", func() { | |
var pid int | |
BeforeEach(func() { | |
cmd := exec.Command("sleep", "10") | |
Expect(cmd.Start()).To(Succeed()) | |
go func() { | |
Expect(cmd.Wait()).To(Succeed()) | |
}() | |
pid = cmd.Process.Pid | |
}) | |
It("runs for at least 5 seconds", func() { | |
Consistently(func() bool { | |
return unix.Kill(pid, unix.Signal(0)) == nil | |
}, time.Second*5, time.Second).Should(BeTrue()) | |
}) | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment