test/experiment_test.rb in verdict-0.9.0 vs test/experiment_test.rb in verdict-0.10.0

- old
+ new

@@ -420,6 +420,34 @@ storage :none end assert_kind_of Verdict::Storage::MockStorage, e.storage end + + def test_cleanup + redis = ::Redis.new(host: REDIS_HOST, port: REDIS_PORT) + storage = Verdict::Storage::RedisStorage.new(redis) + experiment = Verdict::Experiment.new(:cleanup_test) do + groups { group :all, 100 } + storage storage, store_unqualified: true + end + + experiment.assign("something") + assert_operator redis, :exists, "experiments/cleanup_test" + + experiment.cleanup + refute_operator redis, :exists, "experiments/cleanup_test" + ensure + redis.del("experiments/cleanup_test") + end + + def test_cleanup_without_redis + experiment = Verdict::Experiment.new(:cleanup_test) do + groups { group :all, 100 } + end + + assert_raises(NotImplementedError) do + experiment.assign("something") + experiment.cleanup + end + end end