diff options
Diffstat (limited to 'spec/lib/gitlab/ci/project_config')
-rw-r--r-- | spec/lib/gitlab/ci/project_config/repository_spec.rb | 47 | ||||
-rw-r--r-- | spec/lib/gitlab/ci/project_config/source_spec.rb | 23 |
2 files changed, 70 insertions, 0 deletions
diff --git a/spec/lib/gitlab/ci/project_config/repository_spec.rb b/spec/lib/gitlab/ci/project_config/repository_spec.rb new file mode 100644 index 00000000000..2105b691d9e --- /dev/null +++ b/spec/lib/gitlab/ci/project_config/repository_spec.rb @@ -0,0 +1,47 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Gitlab::Ci::ProjectConfig::Repository do + let(:project) { create(:project, :custom_repo, files: files) } + let(:sha) { project.repository.head_commit.sha } + let(:files) { { 'README.md' => 'hello' } } + + subject(:config) { described_class.new(project, sha, nil, nil, nil) } + + describe '#content' do + subject(:content) { config.content } + + context 'when file is in repository' do + let(:config_content_result) do + <<~CICONFIG + --- + include: + - local: ".gitlab-ci.yml" + CICONFIG + end + + let(:files) { { '.gitlab-ci.yml' => 'content' } } + + it { is_expected.to eq(config_content_result) } + end + + context 'when file is not in repository' do + it { is_expected.to be_nil } + end + + context 'when Gitaly raises error' do + before do + allow(project.repository).to receive(:gitlab_ci_yml_for).and_raise(GRPC::Internal) + end + + it { is_expected.to be_nil } + end + end + + describe '#source' do + subject { config.source } + + it { is_expected.to eq(:repository_source) } + end +end diff --git a/spec/lib/gitlab/ci/project_config/source_spec.rb b/spec/lib/gitlab/ci/project_config/source_spec.rb new file mode 100644 index 00000000000..dda5c7cdce8 --- /dev/null +++ b/spec/lib/gitlab/ci/project_config/source_spec.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Gitlab::Ci::ProjectConfig::Source do + let_it_be(:custom_config_class) { Class.new(described_class) } + let_it_be(:project) { build_stubbed(:project) } + let_it_be(:sha) { '123456' } + + subject(:custom_config) { custom_config_class.new(project, sha, nil, nil, nil) } + + describe '#content' do + subject(:content) { custom_config.content } + + it { expect { content }.to raise_error(NotImplementedError) } + end + + describe '#source' do + subject(:source) { custom_config.source } + + it { expect { source }.to raise_error(NotImplementedError) } + end +end |