debian-mirror-gitlab/spec/tasks/gitlab/container_registry_rake_spec.rb

62 lines
1.6 KiB
Ruby
Raw Normal View History

2020-06-23 00:09:42 +05:30
# frozen_string_literal: true
require 'rake_helper'
2020-07-28 23:09:34 +05:30
RSpec.describe 'gitlab:container_registry namespace rake tasks' do
2020-06-23 00:09:42 +05:30
let_it_be(:api_url) { 'http://registry.gitlab' }
before :all do
Rake.application.rake_require 'tasks/gitlab/container_registry'
end
2020-07-28 23:09:34 +05:30
describe '#configure' do
2020-06-23 00:09:42 +05:30
subject { run_rake_task('gitlab:container_registry:configure') }
shared_examples 'invalid config' do
2020-07-28 23:09:34 +05:30
it 'does not call UpdateContainerRegistryInfoService' do
expect_any_instance_of(UpdateContainerRegistryInfoService).not_to receive(:execute)
2020-06-23 00:09:42 +05:30
subject
end
it 'does not raise an error' do
expect { subject }.not_to raise_error
end
it 'prints a warning message' do
2020-07-28 23:09:34 +05:30
expect { subject }.to output("Registry is not enabled or registry api url is not present.\n").to_stdout
2020-06-23 00:09:42 +05:30
end
end
context 'when container registry is disabled' do
before do
stub_container_registry_config(enabled: false)
end
it_behaves_like 'invalid config'
end
context 'when container registry api_url is blank' do
before do
stub_container_registry_config(api_url: '')
end
it_behaves_like 'invalid config'
end
2020-07-28 23:09:34 +05:30
context 'when container registry is enabled and api_url is not blank' do
2020-06-23 00:09:42 +05:30
before do
2020-07-28 23:09:34 +05:30
stub_container_registry_config(enabled: true, api_url: api_url)
2020-06-23 00:09:42 +05:30
end
2020-07-28 23:09:34 +05:30
it 'calls UpdateContainerRegistryInfoService' do
expect_next_instance_of(UpdateContainerRegistryInfoService) do |service|
expect(service).to receive(:execute)
2020-06-23 00:09:42 +05:30
end
2020-07-28 23:09:34 +05:30
subject
2020-06-23 00:09:42 +05:30
end
end
end
end