2021-05-19 20:10:36 -04:00
|
|
|
# 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-08-11 05:10:00 -04:00
|
|
|
let(:changed_files) { ['metrics/counts_7d/test_metric.yml'] }
|
2021-05-19 20:10:36 -04:00
|
|
|
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-10-27 05:12:12 -04:00
|
|
|
let(:mr_labels) { [] }
|
2021-05-19 20:10:36 -04:00
|
|
|
|
|
|
|
before do
|
|
|
|
allow(fake_helper).to receive(:mr_has_labels?).with('product intelligence').and_return(true)
|
2021-10-27 05:12:12 -04:00
|
|
|
allow(fake_helper).to receive(:mr_labels).and_return(mr_labels)
|
2021-05-19 20:10:36 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it { is_expected.to match_array(expected_labels) }
|
|
|
|
|
2021-10-27 05:12:12 -04:00
|
|
|
context 'with product intelligence::review pending' do
|
|
|
|
let(:mr_labels) { ['product intelligence::review pending'] }
|
|
|
|
|
|
|
|
it { is_expected.to be_empty }
|
2021-05-19 20:10:36 -04:00
|
|
|
end
|
|
|
|
|
2021-10-27 05:12:12 -04:00
|
|
|
context 'with product intelligence::approved' do
|
|
|
|
let(:mr_labels) { ['product intelligence::approved'] }
|
|
|
|
|
|
|
|
it { is_expected.to be_empty }
|
|
|
|
end
|
2021-05-19 20:10:36 -04:00
|
|
|
end
|
2021-09-27 14:12:38 -04:00
|
|
|
|
|
|
|
context 'with growth experiment label' do
|
|
|
|
before do
|
|
|
|
allow(fake_helper).to receive(:mr_has_labels?).with('growth experiment').and_return(true)
|
|
|
|
end
|
|
|
|
|
|
|
|
it { is_expected.to be_empty }
|
|
|
|
end
|
2021-05-19 20:10:36 -04:00
|
|
|
end
|
|
|
|
end
|