Sha256: 83bf12b1708d3f9c65821c7ff17d413965a62432b7b4c42347386c479a60b11b

Contents?: true

Size: 1.05 KB

Versions: 55

Compression:

Stored size: 1.05 KB

Contents

require 'dynflow/testing'
module ForemanTasks
  module TestHelpers
    def self.use_in_memory_sqlite!
      raise 'the in thread world have already been initialized' if @test_in_thread_world
      @use_in_memory_sqlite = true
    end

    def self.test_in_thread_world
      return @test_in_thread_world if @test_in_thread_world
      world_config = ForemanTasks.dynflow.config.world_config
      if @use_in_memory_sqlite
        world_config.persistence_adapter = lambda do |*_args|
          ::ForemanTasks::Dynflow::Persistence.new('adapter' => 'sqlite', 'database' => ':memory:')
        end
      end
      @test_in_thread_world = ::Dynflow::Testing::InThreadWorld.new(world_config)
    end

    module WithInThreadExecutor
      extend ActiveSupport::Concern
      included do
        setup do
          @old_dynflow_world = ForemanTasks.dynflow.world
          ForemanTasks.dynflow.world = ForemanTasks::TestHelpers.test_in_thread_world
        end

        teardown do
          ForemanTasks.dynflow.world = @old_dynflow_world
        end
      end
    end
  end
end

Version data entries

55 entries across 55 versions & 1 rubygems

Version Path
foreman-tasks-4.1.6 lib/foreman_tasks/test_helpers.rb
foreman-tasks-5.2.3 lib/foreman_tasks/test_helpers.rb
foreman-tasks-5.2.2 lib/foreman_tasks/test_helpers.rb
foreman-tasks-5.2.1 lib/foreman_tasks/test_helpers.rb
foreman-tasks-5.2.0 lib/foreman_tasks/test_helpers.rb
foreman-tasks-5.1.1 lib/foreman_tasks/test_helpers.rb
foreman-tasks-5.1.0 lib/foreman_tasks/test_helpers.rb
foreman-tasks-4.1.5 lib/foreman_tasks/test_helpers.rb
foreman-tasks-4.1.4 lib/foreman_tasks/test_helpers.rb
foreman-tasks-4.1.3 lib/foreman_tasks/test_helpers.rb
foreman-tasks-3.0.6 lib/foreman_tasks/test_helpers.rb
foreman-tasks-5.0.0 lib/foreman_tasks/test_helpers.rb
foreman-tasks-4.1.2 lib/foreman_tasks/test_helpers.rb
foreman-tasks-4.1.1 lib/foreman_tasks/test_helpers.rb
foreman-tasks-4.0.1 lib/foreman_tasks/test_helpers.rb
foreman-tasks-4.1.0 lib/foreman_tasks/test_helpers.rb
foreman-tasks-3.0.5 lib/foreman_tasks/test_helpers.rb
foreman-tasks-4.0.0 lib/foreman_tasks/test_helpers.rb
foreman-tasks-3.0.4 lib/foreman_tasks/test_helpers.rb
foreman-tasks-2.0.3 lib/foreman_tasks/test_helpers.rb