Sha256: f0fda0034bed2cfec07d70c2bb772e506268d6d2187d91319e0358f306603e6c

Contents?: true

Size: 1.23 KB

Versions: 8

Compression:

Stored size: 1.23 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.send(:get, @experiment.handle.to_s, 'started_at').nil?
    @experiment.send(:ensure_experiment_has_started)
    refute @storage.send(:get, @experiment.handle.to_s, 'started_at').nil?
    assert_instance_of Time, @experiment.started_at
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
verdict-0.16.1 test/storage/memory_storage_test.rb
verdict-0.16.0 test/storage/memory_storage_test.rb
verdict-0.15.2 test/storage/memory_storage_test.rb
verdict-0.15.1 test/storage/memory_storage_test.rb
verdict-0.15.0 test/storage/memory_storage_test.rb
verdict-0.14.0 test/storage/memory_storage_test.rb
verdict-0.13.0 test/storage/memory_storage_test.rb
verdict-0.12.0 test/storage/memory_storage_test.rb