From 30b2bd973025a727e66de5f3aeb61caac7de9c0b Mon Sep 17 00:00:00 2001 From: Thomas Schmidt Date: Tue, 12 Mar 2024 17:26:24 +0100 Subject: [PATCH 1/2] skip tests that don't work with sqlite --- spec/lib/rmt/cli/smt_importer_spec.rb | 2 +- spec/lib/rmt/lockfile_spec.rb | 2 +- spec/lib/rmt/scc_spec.rb | 2 +- spec/models/repository_spec.rb | 6 +++--- spec/rails_helper.rb | 6 ++++++ spec/services/repository_service_spec.rb | 2 +- 6 files changed, 13 insertions(+), 7 deletions(-) diff --git a/spec/lib/rmt/cli/smt_importer_spec.rb b/spec/lib/rmt/cli/smt_importer_spec.rb index d77404a52..17063bbc0 100644 --- a/spec/lib/rmt/cli/smt_importer_spec.rb +++ b/spec/lib/rmt/cli/smt_importer_spec.rb @@ -1,7 +1,7 @@ require 'rails_helper' require 'rmt/cli/smt_importer' -describe RMT::CLI::SMTImporter do +describe RMT::CLI::SMTImporter, :skip_sqlite do let(:data_dir) { File.join(Dir.pwd, 'spec/fixtures/files/csv') } let(:no_systems) { false } let(:importer) { described_class.new(data_dir, no_systems) } diff --git a/spec/lib/rmt/lockfile_spec.rb b/spec/lib/rmt/lockfile_spec.rb index d1b86f968..c06644bc3 100644 --- a/spec/lib/rmt/lockfile_spec.rb +++ b/spec/lib/rmt/lockfile_spec.rb @@ -3,7 +3,7 @@ RSpec.describe RMT::Lockfile do let(:lock_name) { nil } - describe '#lock' do + describe '#lock', :skip_sqlite do subject(:lock) { described_class.lock(lock_name) { nil } } context 'with an unnamed lock' do diff --git a/spec/lib/rmt/scc_spec.rb b/spec/lib/rmt/scc_spec.rb index a4732b0cd..94b2a739d 100644 --- a/spec/lib/rmt/scc_spec.rb +++ b/spec/lib/rmt/scc_spec.rb @@ -238,7 +238,7 @@ described_class.new.sync end - it 'removes existing predecessor associations' do + it 'removes existing predecessor associations', :skip_sqlite do expect { ProductPredecessorAssociation.find(existing_association.id) }.to raise_error(ActiveRecord::RecordNotFound) end end diff --git a/spec/models/repository_spec.rb b/spec/models/repository_spec.rb index 3c958ac15..3c49cd6fa 100644 --- a/spec/models/repository_spec.rb +++ b/spec/models/repository_spec.rb @@ -146,7 +146,7 @@ expect(friendly_id).to eq('my-repo-100000') end - it 'appends with unicode within the chain' do + it 'appends with unicode within the chain', :skip_sqlite do create(:repository, friendly_id: 'my-repo') create(:repository, friendly_id: 'my-repö-1') expect(friendly_id).to eq('my-repo-2') @@ -165,13 +165,13 @@ expect(friendly_id).to eq('dümmy-repö') end - it 'appends with unicode within the chain' do + it 'appends with unicode within the chain', :skip_sqlite do create(:repository, friendly_id: 'dummy-repo') create(:repository, friendly_id: 'dümmy-repö-1') expect(friendly_id).to eq('dümmy-repö-2') end - it 'correctly appends' do + it 'correctly appends', :skip_sqlite do create(:repository, friendly_id: 'dummy-repo') create(:repository, friendly_id: 'dummy-repo-1') expect(friendly_id).to eq('dümmy-repö-2') diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index 5d71fea9f..f5b47b1e6 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -58,6 +58,12 @@ config.filter_rails_from_backtrace! # arbitrary gems may also be filtered via: # config.filter_gems_from_backtrace("gem name") + + # Skipping some tests when running with (experimental) sqlite backend. + # Some tests / code parts are using specific mysql behavior + if ActiveRecord::Base.connection.adapter_name == 'SQLite' + config.filter_run_excluding :skip_sqlite => true + end end Shoulda::Matchers.configure do |config| diff --git a/spec/services/repository_service_spec.rb b/spec/services/repository_service_spec.rb index 1387ea3b0..0035395b5 100644 --- a/spec/services/repository_service_spec.rb +++ b/spec/services/repository_service_spec.rb @@ -88,7 +88,7 @@ it('is not custom') { expect(repository.custom?).to eq(true) } - context 'already existing repositories with changing URL' do + context 'already existing repositories with changing URL', :skip_sqlite do subject(:repository) do service.create_repository!(product, url, attributes, custom: custom).reload url = 'https://foo.bar.com/bar/foo' From d380414ae3bd537c464ed06ffaaf5fd439bd4f1a Mon Sep 17 00:00:00 2001 From: Thomas Schmidt Date: Tue, 12 Mar 2024 17:28:16 +0100 Subject: [PATCH 2/2] add step to ci to run tests with sqlite --- .github/workflows/lint-unit.yml | 5 +++++ spec/rails_helper.rb | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/lint-unit.yml b/.github/workflows/lint-unit.yml index 9ac44b6eb..66bf3f77c 100644 --- a/.github/workflows/lint-unit.yml +++ b/.github/workflows/lint-unit.yml @@ -83,6 +83,11 @@ jobs: run: | bundle exec rspec --format documentation + - name: Run core tests with sqlite + run: | + sed -i 's/adapter: mysql2/adapter: sqlite3/' config/rmt.yml + bundle exec rspec --format documentation + - name: Run PubCloud engines tests run: | bundle exec rake test:engines diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index f5b47b1e6..9c8bffe57 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -62,7 +62,7 @@ # Skipping some tests when running with (experimental) sqlite backend. # Some tests / code parts are using specific mysql behavior if ActiveRecord::Base.connection.adapter_name == 'SQLite' - config.filter_run_excluding :skip_sqlite => true + config.filter_run_excluding skip_sqlite: true end end