diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 43a3a1e7151..6f08a4e80a6 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -41,6 +41,7 @@ jobs: RUBYGEMS_VERSION: ${{ matrix.rubygems.version }} # Fail hard when Toxiproxy is not running to ensure all tests (even Toxiproxy optional ones) are passing REQUIRE_TOXIPROXY: true + REQUIRE_AVO_PRO: true steps: - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 diff --git a/test/integration/avo/gem_name_reservations_controller_test.rb b/test/integration/avo/gem_name_reservations_controller_test.rb index 7b1e6f3b1e5..57574ab3731 100644 --- a/test/integration/avo/gem_name_reservations_controller_test.rb +++ b/test/integration/avo/gem_name_reservations_controller_test.rb @@ -13,7 +13,7 @@ class Avo::GemNameReservationsControllerTest < ActionDispatch::IntegrationTest end test "resource search_query scope" do - skip "avo-pro needed to run this test" unless defined?(Avo::Pro) + requires_avo_pro admin_sign_in_as create(:admin_github_user, :is_admin) create(:gem_name_reservation, name: "hello") diff --git a/test/test_helper.rb b/test/test_helper.rb index 94a99a0557c..f3f71c31d47 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -115,6 +115,16 @@ def requires_toxiproxy skip("Toxiproxy is not running, but was required for this test.") end + def requires_avo_pro + return if Avo.configuration.license == "advanced" && defined?(Avo::Pro) + + if ENV["REQUIRE_AVO_PRO"] + raise "REQUIRE_AVO_PRO is set but Avo::Pro is missing in #{Rails.env}." \ + "\nRAILS_GROUPS=#{ENV['RAILS_GROUPS'].inspect}\nAvo.license=#{Avo.license.inspect}" + end + skip "avo pro is not present but was required for this test" + end + def assert_changed(object, *attributes) original_attributes = attributes.index_with { |a| object.send(a) } yield if block_given? @@ -242,7 +252,7 @@ class SystemTest < ActionDispatch::IntegrationTest class AdminPolicyTestCase < ActiveSupport::TestCase def setup - skip "avo-pro needed to run this test" unless defined?(Avo::Pro) + requires_avo_pro @authorization_client = Admin::AuthorizationClient.new end