本文整理匯總了Golang中github.com/tedsuo/ifrit/fake_runner.TestRunner.WaitForCall方法的典型用法代碼示例。如果您正苦於以下問題:Golang TestRunner.WaitForCall方法的具體用法?Golang TestRunner.WaitForCall怎麽用?Golang TestRunner.WaitForCall使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/tedsuo/ifrit/fake_runner.TestRunner
的用法示例。
在下文中一共展示了TestRunner.WaitForCall方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1:
childRunner1.TriggerReady()
childRunner2.TriggerReady()
childRunner3.TriggerReady()
Eventually(groupProcess.Ready()).Should(BeClosed())
})
Describe("when all the runners are ready", func() {
var (
signal1 <-chan os.Signal
signal2 <-chan os.Signal
signal3 <-chan os.Signal
)
BeforeEach(func() {
signal1 = childRunner1.WaitForCall()
childRunner1.TriggerReady()
signal2 = childRunner2.WaitForCall()
childRunner2.TriggerReady()
signal3 = childRunner3.WaitForCall()
childRunner3.TriggerReady()
Eventually(groupProcess.Ready()).Should(BeClosed())
})
Describe("when it receives a signal", func() {
BeforeEach(func() {
groupProcess.Signal(syscall.SIGUSR2)
})
It("sends the signal to all child runners", func() {
示例2:
member1 = grouper.Member{"child1", childRunner1}
member2 = grouper.Member{"child2", childRunner2}
member3 = grouper.Member{"child3", childRunner3}
pool = grouper.NewDynamic(nil, 3, 2)
client = pool.Client()
poolProcess = ifrit.Envoke(pool)
insert := client.Inserter()
Eventually(insert).Should(BeSent(member1))
Eventually(insert).Should(BeSent(member2))
Eventually(insert).Should(BeSent(member3))
})
It("returns a process when the member is present", func() {
signal1 := childRunner1.WaitForCall()
p, ok := client.Get("child1")
Ω(ok).Should(BeTrue())
p.Signal(syscall.SIGUSR2)
Eventually(signal1).Should(Receive(Equal(syscall.SIGUSR2)))
})
It("returns false when the member is not present", func() {
_, ok := client.Get("blah")
Ω(ok).Should(BeFalse())
})
})
Describe("Insert", func() {
var member1, member2, member3 grouper.Member
示例3:
"github.com/tedsuo/ifrit/proxy"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("Proxy", func() {
var testRunner *fake_runner.TestRunner
var process ifrit.Process
var proxySignals chan os.Signal
var receivedSignals <-chan os.Signal
BeforeEach(func() {
proxySignals = make(chan os.Signal, 1)
testRunner = fake_runner.NewTestRunner()
process = ifrit.Background(proxy.New(proxySignals, testRunner))
receivedSignals = testRunner.WaitForCall()
testRunner.TriggerReady()
})
It("sends the proxied signals to the embedded runner", func() {
proxySignals <- os.Interrupt
Eventually(receivedSignals).Should(Receive(Equal(os.Interrupt)))
})
It("sends the process signals to the embedded runner", func() {
process.Signal(os.Interrupt)
Eventually(receivedSignals).Should(Receive(Equal(os.Interrupt)))
})
})