BigW Consortium Gitlab

Add specs

parent 77295de4
......@@ -19,4 +19,55 @@ describe Ci::Build, models: true do
expect(build.trace).to eq(test_trace)
end
end
describe '#has_trace_file?' do
context 'when there is no trace' do
it { expect(build.has_trace_file?).to be_falsey }
it { expect(build.trace).to be_nil }
end
context 'when there is a trace' do
context 'when trace is stored in file' do
before do
build.trace = test_trace
build.save
end
it { expect(build.has_trace_file?).to be_truthy }
it { expect(build.trace).to eq(test_trace) }
end
context 'when trace is stored in old file' do
before do
build.trace = test_trace
build.save
build.project.ci_id = 999
build.project.save
FileUtils.mkdir_p(build.old_dir_to_trace)
FileUtils.mv(build.path_to_trace, build.old_path_to_trace)
end
it { expect(build.has_trace_file?).to be_truthy }
it { expect(build.trace).to eq(test_trace) }
end
context 'when there is stored in DB' do
class Ci::Build
def write_db_trace=(trace)
write_attribute :trace, trace
end
end
before do
build.write_db_trace = test_trace
build.save
end
it { expect(build.has_trace_file?).to be_falsey }
it { expect(build.trace).to eq(test_trace) }
end
end
end
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment