diff options
author | Timothy Andrew <mail@timothyandrew.net> | 2016-09-07 08:55:01 +0300 |
---|---|---|
committer | Timothy Andrew <mail@timothyandrew.net> | 2016-09-07 09:42:51 +0300 |
commit | dd112ef1174b2b0207769a361cddfc44dfe2e6d0 (patch) | |
tree | cc78741339cbfcb938c5da892d5c09db0587fe7e /spec/support/cycle_analytics_helpers.rb | |
parent | 0f44c5a56fdc5986797808c508d7b42236cee450 (diff) |
Test the `staging` cycle analytics phase.
Remove overlap from the "start + end" durations in the happy test
case. For the `staging` phase, the end time is the _first_ deployment
that happens after the MR merge.
If we have 5 MRs where the `start_time`s (merge time) are the
same, and all the `end_time`s (deploy to production) a few days from
now, only the earliest deploy will get picked up, because that
consitutes a deploy for _all_ the MRs.
We fix this by removing overlap. Every `start_time` is now generated to
be _after_ the preceding `end_time`.
Diffstat (limited to 'spec/support/cycle_analytics_helpers.rb')
-rw-r--r-- | spec/support/cycle_analytics_helpers.rb | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/spec/support/cycle_analytics_helpers.rb b/spec/support/cycle_analytics_helpers.rb index b2ca42d7cce..4819f8b517a 100644 --- a/spec/support/cycle_analytics_helpers.rb +++ b/spec/support/cycle_analytics_helpers.rb @@ -26,10 +26,10 @@ module CycleAnalyticsHelpers context "start condition: #{start_time_conditions.map(&:first).to_sentence}" do context "end condition: #{end_time_conditions.map(&:first).to_sentence}" do it "finds the median of available durations between the two conditions" do - time_differences = Array.new(5) do + time_differences = Array.new(5) do |index| data = data_fn[self] - start_time = Time.now - end_time = rand(1..10).days.from_now + start_time = (index * 10).days.from_now + end_time = start_time + rand(1..5).days start_time_conditions.each do |condition_name, condition_fn| Timecop.freeze(start_time) { condition_fn[self, data] } @@ -43,7 +43,7 @@ module CycleAnalyticsHelpers end median_time_difference = time_differences.sort[2] - expect(subject.send(phase)).to be_within(2).of(median_time_difference) + expect(subject.send(phase)).to be_within(5).of(median_time_difference) end context "when the data belongs to another project" do |