debian-mirror-gitlab/spec/tooling/danger/product_intelligence_spec.rb

90 lines
2.6 KiB
Ruby
Raw Normal View History

2021-09-04 01:27:46 +05:30
# frozen_string_literal: true
require 'gitlab-dangerfiles'
require 'gitlab/dangerfiles/spec_helper'
require_relative '../../../tooling/danger/product_intelligence'
require_relative '../../../tooling/danger/project_helper'
RSpec.describe Tooling::Danger::ProductIntelligence do
include_context "with dangerfile"
subject(:product_intelligence) { fake_danger.new(helper: fake_helper) }
let(:fake_danger) { DangerSpecHelper.fake_danger.include(described_class) }
2021-10-27 15:23:28 +05:30
let(:changed_files) { ['metrics/counts_7d/test_metric.yml'] }
2021-09-04 01:27:46 +05:30
let(:changed_lines) { ['+tier: ee'] }
before do
allow(fake_helper).to receive(:all_changed_files).and_return(changed_files)
allow(fake_helper).to receive(:changed_lines).and_return(changed_lines)
end
describe '#missing_labels' do
subject { product_intelligence.missing_labels }
let(:ci_env) { true }
before do
allow(fake_helper).to receive(:mr_has_labels?).and_return(false)
allow(fake_helper).to receive(:ci?).and_return(ci_env)
end
context 'with ci? false' do
let(:ci_env) { false }
it { is_expected.to be_empty }
end
context 'with ci? true' do
let(:expected_labels) { ['product intelligence', 'product intelligence::review pending'] }
it { is_expected.to match_array(expected_labels) }
end
context 'with product intelligence label' do
let(:expected_labels) { ['product intelligence::review pending'] }
2021-12-11 22:18:48 +05:30
let(:mr_labels) { [] }
2021-09-04 01:27:46 +05:30
before do
allow(fake_helper).to receive(:mr_has_labels?).with('product intelligence').and_return(true)
2021-12-11 22:18:48 +05:30
allow(fake_helper).to receive(:mr_labels).and_return(mr_labels)
2021-09-04 01:27:46 +05:30
end
it { is_expected.to match_array(expected_labels) }
2021-12-11 22:18:48 +05:30
context 'with product intelligence::review pending' do
let(:mr_labels) { ['product intelligence::review pending'] }
it { is_expected.to be_empty }
2021-09-04 01:27:46 +05:30
end
2021-12-11 22:18:48 +05:30
context 'with product intelligence::approved' do
let(:mr_labels) { ['product intelligence::approved'] }
it { is_expected.to be_empty }
end
2021-09-04 01:27:46 +05:30
end
2022-01-26 12:08:38 +05:30
end
describe '#skip_review' do
subject { product_intelligence.skip_review? }
2021-11-18 22:05:49 +05:30
context 'with growth experiment label' do
before do
allow(fake_helper).to receive(:mr_has_labels?).with('growth experiment').and_return(true)
end
2022-01-26 12:08:38 +05:30
it { is_expected.to be true }
end
context 'without growth experiment label' do
before do
allow(fake_helper).to receive(:mr_has_labels?).with('growth experiment').and_return(false)
end
it { is_expected.to be false }
2021-11-18 22:05:49 +05:30
end
2021-09-04 01:27:46 +05:30
end
end