2022-10-11 01:57:18 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
RSpec.describe QA::Tools::Ci::FfChanges do
|
|
|
|
subject(:ff_changes) { described_class.new(mr_diff) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
allow(Gitlab::QA::TestLogger).to receive(:logger).and_return(Logger.new(StringIO.new))
|
|
|
|
end
|
|
|
|
|
|
|
|
context "with merge request pipeline" do
|
|
|
|
let(:deleted_file) { false }
|
|
|
|
let(:mr_diff) do
|
|
|
|
[
|
|
|
|
{
|
2023-05-27 22:25:52 +05:30
|
|
|
path: "config/feature_flags/development/async_commit_diff_files.yml",
|
2022-10-11 01:57:18 +05:30
|
|
|
deleted_file: deleted_file
|
|
|
|
}
|
|
|
|
]
|
|
|
|
end
|
|
|
|
|
|
|
|
before do
|
|
|
|
allow(File).to receive(:read)
|
|
|
|
.with(File.expand_path("../#{mr_diff.first[:path]}", QA::Runtime::Path.qa_root))
|
2023-05-27 22:25:52 +05:30
|
|
|
.and_return(File.read("spec/fixtures/ff/async_commit_diff_files.yml"))
|
2022-10-11 01:57:18 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
context "with changed feature flag" do
|
|
|
|
it "returns inverse ff state option" do
|
2023-05-27 22:25:52 +05:30
|
|
|
expect(ff_changes.fetch).to eq("async_commit_diff_files=enabled")
|
2022-10-11 01:57:18 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context "with deleted feature flag" do
|
|
|
|
let(:deleted_file) { true }
|
|
|
|
|
|
|
|
it "returns deleted ff state option" do
|
2023-05-27 22:25:52 +05:30
|
|
|
expect(ff_changes.fetch).to eq("async_commit_diff_files=deleted")
|
2022-10-11 01:57:18 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context "without merge request pipeline" do
|
|
|
|
let(:mr_diff) { [] }
|
|
|
|
|
|
|
|
context "with empty mr diff" do
|
|
|
|
it "doesn't return any ff options" do
|
|
|
|
expect(ff_changes.fetch).to be_nil
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|