...
1 package helper
2
3 import (
4 "time"
5
6 . "github.com/onsi/ginkgo/v2"
7 . "github.com/onsi/gomega"
8 "github.com/onsi/gomega/types"
9 )
10
11
12
13
14 func WaitAppReadyInContainer(
15 cmp Component,
16 container string,
17 cmd []string,
18 pollingInterval time.Duration,
19 timeout time.Duration,
20 stdoutMatcher types.GomegaMatcher,
21 stderrMatcher types.GomegaMatcher,
22 ) {
23 if stdoutMatcher == nil && stderrMatcher == nil {
24 Fail("Please specify either stdoutMatcher or stderrMatcher!")
25 }
26 Eventually(func(g Gomega) {
27 stdout, stderr := cmp.Exec(container, cmd, nil)
28 if stdoutMatcher != nil {
29 g.Expect(stdout).Should(stdoutMatcher)
30 }
31 if stderrMatcher != nil {
32 g.Expect(stderr).Should(stderrMatcher)
33 }
34 }).WithPolling(pollingInterval).WithTimeout(timeout).Should(Succeed())
35 }
36
View as plain text