diff options
Diffstat (limited to 'spec/support/shared_examples/finders/packages/debian/distributions_finder_shared_examples.rb')
-rw-r--r-- | spec/support/shared_examples/finders/packages/debian/distributions_finder_shared_examples.rb | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/spec/support/shared_examples/finders/packages/debian/distributions_finder_shared_examples.rb b/spec/support/shared_examples/finders/packages/debian/distributions_finder_shared_examples.rb new file mode 100644 index 00000000000..2700d29bf0e --- /dev/null +++ b/spec/support/shared_examples/finders/packages/debian/distributions_finder_shared_examples.rb @@ -0,0 +1,79 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.shared_examples 'Debian Distributions Finder' do |factory, can_freeze| + let_it_be(:distribution_with_suite, freeze: can_freeze) { create(factory, suite: 'mysuite') } + let_it_be(:container) { distribution_with_suite.container } + let_it_be(:distribution_with_same_container, freeze: can_freeze) { create(factory, container: container ) } + let_it_be(:distribution_with_same_codename, freeze: can_freeze) { create(factory, codename: distribution_with_suite.codename ) } + let_it_be(:distribution_with_same_suite, freeze: can_freeze) { create(factory, suite: distribution_with_suite.suite ) } + let_it_be(:distribution_with_codename_and_suite_flipped, freeze: can_freeze) { create(factory, codename: distribution_with_suite.suite, suite: distribution_with_suite.codename) } + + let(:params) { {} } + let(:service) { described_class.new(container, params) } + + subject { service.execute.to_a } + + context 'by codename' do + context 'with existing codename' do + let(:params) { { codename: distribution_with_suite.codename } } + + it 'finds distributions by codename' do + is_expected.to contain_exactly(distribution_with_suite) + end + end + + context 'with non-existing codename' do + let(:params) { { codename: 'does_not_exists' } } + + it 'finds nothing' do + is_expected.to be_empty + end + end + end + + context 'by suite' do + context 'with existing suite' do + let(:params) { { suite: 'mysuite' } } + + it 'finds distribution by suite' do + is_expected.to contain_exactly(distribution_with_suite) + end + end + + context 'with non-existing suite' do + let(:params) { { suite: 'does_not_exists' } } + + it 'finds nothing' do + is_expected.to be_empty + end + end + end + + context 'by codename_or_suite' do + context 'with existing codename' do + let(:params) { { codename_or_suite: distribution_with_suite.codename } } + + it 'finds distribution by codename' do + is_expected.to contain_exactly(distribution_with_suite) + end + end + + context 'with existing suite' do + let(:params) { { codename_or_suite: 'mysuite' } } + + it 'finds distribution by suite' do + is_expected.to contain_exactly(distribution_with_suite) + end + end + + context 'with non-existing suite' do + let(:params) { { codename_or_suite: 'does_not_exists' } } + + it 'finds nothing' do + is_expected.to be_empty + end + end + end +end |