We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent e522da5 commit 01cd1d8Copy full SHA for 01cd1d8
1 file changed
logging/spec/quickstart_spec.rb
@@ -17,6 +17,15 @@
17
18
describe "Logging Quickstart" do
19
20
+ # Simple wait method. Test for condition 5 times, delaying 1 second each time
21
+ def wait_until times: 5, delay: 1, &condition
22
+ times.times do
23
+ return if condition.call
24
+ sleep delay
25
+ end
26
+ raise "Condition not met. Waited #{times} times with #{delay} sec delay"
27
28
+
29
it "logs a new entry" do
30
entry_filter = 'logName:"my-log" textPayload:"Hello, world!"'
31
gcloud = Google::Cloud.new ENV["GOOGLE_CLOUD_PROJECT"]
@@ -38,7 +47,9 @@
38
47
"Logged Hello, world!\n"
39
48
).to_stdout
40
49
41
- sleep(5)
50
+ wait_until(delay: 2) do
51
+ logging.entries(filter: entry_filter).any?
52
42
53
43
54
entries = logging.entries filter: entry_filter
44
55
expect(entries).to_not be_empty
0 commit comments