提交 031b1623 编写于 作者: L Lin Jen-Shin

Fix test for Pipeline#duration

上级 7e32e2ef
......@@ -124,17 +124,22 @@ describe Ci::Pipeline, models: true do
describe 'state machine' do
let(:current) { Time.now.change(usec: 0) }
let(:build) { create :ci_build, name: 'build1', pipeline: pipeline }
let(:build) { create_build('build1', current - 60) }
let(:another_build) { create_build('build2', current + 20) }
describe '#duration' do
before do
travel_to(current - 120) do
pipeline.run
end
pipeline.run
travel_to(current) do
pipeline.succeed
build.success
end
travel_to(current + 80) do
another_build.drop
end
pipeline.drop
end
it 'matches sum of builds duration' do
......@@ -169,6 +174,13 @@ describe Ci::Pipeline, models: true do
expect(pipeline.reload.finished_at).to be_nil
end
end
def create_build(name, started_at = current)
create(:ci_build,
name: name,
pipeline: pipeline,
started_at: started_at)
end
end
describe '#branch?' do
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册