Skip to content

Commit 578261d

Browse files
committed
(PUP-12061) Create example group for splay tests
Memoize the jobs so it's clearer which jobs 0 and 1 are.
1 parent 7ac64a8 commit 578261d

File tree

1 file changed

+19
-11
lines changed

1 file changed

+19
-11
lines changed

spec/unit/daemon_spec.rb

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ def run_loop(jobs)
6060
end
6161

6262
describe "when starting" do
63+
let(:reparse_run) { scheduler.jobs[0] }
64+
let(:agent_run) { scheduler.jobs[1] }
65+
6366
before do
6467
allow(daemon).to receive(:set_signal_traps)
6568
end
@@ -77,19 +80,24 @@ def run_loop(jobs)
7780
it "disables the reparse of configs if the filetimeout is 0" do
7881
Puppet[:filetimeout] = 0
7982
daemon.start
80-
expect(scheduler.jobs[0]).not_to be_enabled
83+
expect(reparse_run).not_to be_enabled
8184
end
8285

83-
it "recalculates splay if splaylimit changes" do
84-
# Set file timeout so the daemon reparses
85-
Puppet[:filetimeout] = 1
86-
Puppet[:splay] = true
87-
allow(agent).to receive(:run)
88-
daemon.start
89-
first_splay = scheduler.jobs[1].splay
90-
allow(Kernel).to receive(:rand).and_return(1738)
91-
scheduler.jobs[0].run(Time.now)
92-
expect(scheduler.jobs[1].splay).to_not eq(first_splay)
86+
describe "and calculating splay" do
87+
before do
88+
# Set file timeout so the daemon reparses
89+
Puppet[:filetimeout] = 1
90+
Puppet[:splay] = true
91+
end
92+
93+
it "recalculates when splaylimit changes" do
94+
allow(agent).to receive(:run)
95+
daemon.start
96+
first_splay = agent_run.splay
97+
allow(Kernel).to receive(:rand).and_return(1738)
98+
reparse_run.run(Time.now)
99+
expect(agent_run.splay).to_not eq(first_splay)
100+
end
93101
end
94102
end
95103

0 commit comments

Comments
 (0)