diff options
author | Lin Jen-Shin <godfat@godfat.org> | 2016-09-02 21:08:26 +0800 |
---|---|---|
committer | Lin Jen-Shin <godfat@godfat.org> | 2016-09-02 21:08:26 +0800 |
commit | defd8899056c26593939243b05c365605ac06fdc (patch) | |
tree | f08b4e6722e73632de2a093419372e4d7e9dd017 /spec | |
parent | 1ccb578ec89df5d69c997920fd512a1db44e309d (diff) | |
download | gitlab-ce-defd8899056c26593939243b05c365605ac06fdc.tar.gz |
Actually we still need to use total - running to get:
real pending time, because that's actually by definition,
(the time that it's not running!)
or we could end up with awfully complicated algorithm :(
Diffstat (limited to 'spec')
-rw-r--r-- | spec/models/ci/pipeline_spec.rb | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/spec/models/ci/pipeline_spec.rb b/spec/models/ci/pipeline_spec.rb index 68a88217afe..4615daa6551 100644 --- a/spec/models/ci/pipeline_spec.rb +++ b/spec/models/ci/pipeline_spec.rb @@ -125,7 +125,8 @@ describe Ci::Pipeline, models: true do describe 'state machine' do let(:current) { Time.now.change(usec: 0) } let(:build) { create_build('build1', current, 10) } - let(:another_build) { create_build('build2', current + 80, 5) } + let(:build_b) { create_build('build2', current, 20) } + let(:build_c) { create_build('build3', current + 40, 20) } describe '#duration and #pending_duration' do before do @@ -136,12 +137,16 @@ describe Ci::Pipeline, models: true do pipeline.save end - travel_to(current + 70) do + travel_to(current + 30) do build.success end - travel_to(current + 145) do - another_build.drop + travel_to(current + 40) do + build_b.drop + end + + travel_to(current + 70) do + build_c.success end pipeline.drop @@ -150,8 +155,8 @@ describe Ci::Pipeline, models: true do it 'matches sum of builds duration' do pipeline.reload - expect(pipeline.duration).to eq(70 - 10 + 145 - 85) - expect(pipeline.pending_duration).to eq(5 + 10 + 5) + expect(pipeline.duration).to eq(40) + expect(pipeline.pending_duration).to eq(35) end end |