From ddea3164250ed5f3886f07cbbc01727fd6dff99c Mon Sep 17 00:00:00 2001 From: Jeremy Daer Date: Sat, 10 Jun 2017 01:07:40 -0700 Subject: Split up the cache test suite so it's easier to understand and extend (#29404) Split up the caching tests as prep for adding a new cache store. Slices the mega test/caching_test.rb into behavior modules, concrete store tests, and cross-cutting store tests. Considering moving cache store behavior modules into lib/ so they may be used for acceptance testing by third parties. --- activesupport/test/cache/cache_entry_test.rb | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 activesupport/test/cache/cache_entry_test.rb (limited to 'activesupport/test/cache/cache_entry_test.rb') diff --git a/activesupport/test/cache/cache_entry_test.rb b/activesupport/test/cache/cache_entry_test.rb new file mode 100644 index 0000000000..e446e39b10 --- /dev/null +++ b/activesupport/test/cache/cache_entry_test.rb @@ -0,0 +1,28 @@ +require "abstract_unit" +require "active_support/cache" + +class CacheEntryTest < ActiveSupport::TestCase + def test_expired + entry = ActiveSupport::Cache::Entry.new("value") + assert !entry.expired?, "entry not expired" + entry = ActiveSupport::Cache::Entry.new("value", expires_in: 60) + assert !entry.expired?, "entry not expired" + Time.stub(:now, Time.now + 61) do + assert entry.expired?, "entry is expired" + end + end + + def test_compress_values + value = "value" * 100 + entry = ActiveSupport::Cache::Entry.new(value, compress: true, compress_threshold: 1) + assert_equal value, entry.value + assert(value.bytesize > entry.size, "value is compressed") + end + + def test_non_compress_values + value = "value" * 100 + entry = ActiveSupport::Cache::Entry.new(value) + assert_equal value, entry.value + assert_equal value.bytesize, entry.size + end +end -- cgit v1.2.3