diff options
author | Alessio Caiazza <acaiazza@gitlab.com> | 2017-09-25 19:54:08 +0300 |
---|---|---|
committer | Alessio Caiazza <acaiazza@gitlab.com> | 2017-10-05 16:42:25 +0300 |
commit | 91f8e734fee1f9e7a16573f7185c48f442e3bb5e (patch) | |
tree | f9eb25a636c95a3bf1bbeaec09b0c36cefc7a7b9 /spec/models/ci | |
parent | f685c368eaa223035b9458b704cfd6ca768f0f7d (diff) |
Add CI build trace sections extractor
Diffstat (limited to 'spec/models/ci')
-rw-r--r-- | spec/models/ci/build_spec.rb | 23 | ||||
-rw-r--r-- | spec/models/ci/build_trace_section_name_spec.rb | 12 | ||||
-rw-r--r-- | spec/models/ci/build_trace_section_spec.rb | 11 |
3 files changed, 46 insertions, 0 deletions
diff --git a/spec/models/ci/build_spec.rb b/spec/models/ci/build_spec.rb index 451968c7342..7fe12f92a2a 100644 --- a/spec/models/ci/build_spec.rb +++ b/spec/models/ci/build_spec.rb @@ -18,6 +18,7 @@ describe Ci::Build do it { is_expected.to belong_to(:trigger_request) } it { is_expected.to belong_to(:erased_by) } it { is_expected.to have_many(:deployments) } + it { is_expected.to have_many(:trace_sections)} it { is_expected.to validate_presence_of(:ref) } it { is_expected.to respond_to(:has_trace?) } it { is_expected.to respond_to(:trace) } @@ -320,6 +321,28 @@ describe Ci::Build do end end + describe '#parse_trace_sections!' do + context "when the build trace has sections markers," do + before do + build.trace.set(File.read(expand_fixture_path('trace/trace_with_sections'))) + end + + it "saves the correct extracted sections" do + expect(build.trace_sections).to be_empty + expect(build.parse_trace_sections!).to be(true) + expect(build.trace_sections).not_to be_empty + end + + it "fails if trace_sections isn't empty" do + expect(build.parse_trace_sections!).to be(true) + expect(build.trace_sections).not_to be_empty + + expect(build.parse_trace_sections!).to be(false) + expect(build.trace_sections).not_to be_empty + end + end + end + describe '#trace' do subject { build.trace } diff --git a/spec/models/ci/build_trace_section_name_spec.rb b/spec/models/ci/build_trace_section_name_spec.rb new file mode 100644 index 00000000000..386ee6880cb --- /dev/null +++ b/spec/models/ci/build_trace_section_name_spec.rb @@ -0,0 +1,12 @@ +require 'spec_helper' + +describe Ci::BuildTraceSectionName, model: true do + subject { build(:ci_build_trace_section_name) } + + it { is_expected.to belong_to(:project) } + it { is_expected.to have_many(:trace_sections)} + + it { is_expected.to validate_presence_of(:project) } + it { is_expected.to validate_presence_of(:name) } + it { is_expected.to validate_uniqueness_of(:name).scoped_to(:project_id) } +end diff --git a/spec/models/ci/build_trace_section_spec.rb b/spec/models/ci/build_trace_section_spec.rb new file mode 100644 index 00000000000..541a9a36fb8 --- /dev/null +++ b/spec/models/ci/build_trace_section_spec.rb @@ -0,0 +1,11 @@ +require 'spec_helper' + +describe Ci::BuildTraceSection, model: true do + it { is_expected.to belong_to(:build)} + it { is_expected.to belong_to(:project)} + it { is_expected.to belong_to(:section_name)} + + it { is_expected.to validate_presence_of(:section_name) } + it { is_expected.to validate_presence_of(:build) } + it { is_expected.to validate_presence_of(:project) } +end |