Sha256: 84c9999f7e08905eb103f1e0a1066bc84fa12ef945727e18d799b31c064c8450

Contents?: true

Size: 1.22 KB

Versions: 12

Compression:

Stored size: 1.22 KB

Contents

require 'test_helper'

class MemoryStorageTest < Minitest::Test

  def setup
    @storage = storage = Verdict::Storage::MemoryStorage.new
    @experiment = Verdict::Experiment.new(:memory_storage) do
      groups { group :all, 100 }
      storage storage, store_unqualified: true
    end

    @subject = stub(id: 'bootscale')
  end

  def test_with_memory_store
    assignment_1 = @experiment.assign(@subject)
    assignment_2 = @experiment.assign(@subject)
    assert !assignment_1.returning?
    assert assignment_2.returning?
  end

  def test_assignment_lookup
    assert @experiment.lookup(@subject).nil?
    @experiment.assign(@subject)
    assert !@experiment.lookup(@subject).nil?
  end

  def test_remove_assignment
    assignment = @experiment.assign(@subject)
    assert !assignment.returning?

    assert @experiment.assign(@subject).returning?
    @storage.remove_assignment(@experiment, @subject.id)
    assert !@experiment.assign(@subject).returning?
  end

  def test_started_at
    assert @storage.get(@experiment.handle.to_s, 'started_at').nil?
    @experiment.send(:ensure_experiment_has_started)
    refute @storage.get(@experiment.handle.to_s, 'started_at').nil?
    assert_instance_of Time, @experiment.started_at
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
verdict-0.11.0 test/storage/memory_storage_test.rb
verdict-0.10.0 test/storage/memory_storage_test.rb
verdict-0.9.0 test/storage/memory_storage_test.rb
verdict-0.8.0 test/storage/memory_storage_test.rb
verdict-0.7.0 test/storage/memory_storage_test.rb
verdict-0.6.3 test/storage/memory_storage_test.rb
verdict-0.6.2 test/storage/memory_storage_test.rb
verdict-0.6.1 test/storage/memory_storage_test.rb
verdict-0.6.0 test/storage/memory_storage_test.rb
verdict-0.5.0 test/storage/memory_storage_test.rb
verdict-0.4.1 test/storage/memory_storage_test.rb
verdict-0.4.0 test/storage/memory_storage_test.rb