mirror of
https://github.com/HoneyryderChuck/httpx.git
synced 2025-10-04 00:00:37 -04:00
the way it was setup, the options class was object shape unfriendly, as the order of creation of ivars was dependent on input and undeterministic; this change fixes it by storing the option names in an array in the class, properly allowing it for extension on plugin calls, freezing it on demand when necessary, and using it to find unsupported options in cases where the former implementation didn't some code was juggled to delay certain instantiations for later, and option_ setters are now private, as they should
33 lines
937 B
Ruby
33 lines
937 B
Ruby
# frozen_string_literal: true
|
|
|
|
require_relative "test_helper"
|
|
require "httpx/plugins/response_cache/file_store"
|
|
|
|
class ResponseCacheFileStoreTest < Minitest::Test
|
|
include ResponseCacheStoreTests
|
|
|
|
def test_internal_store_set
|
|
request = make_request("GET", "http://store-set/")
|
|
assert !File.exist?(store.dir.join(request.response_cache_key))
|
|
response = cached_response(request)
|
|
assert File.exist?(store.dir.join(request.response_cache_key))
|
|
store.set(request, response)
|
|
assert File.exist?(store.dir.join(request.response_cache_key))
|
|
end
|
|
|
|
def test_finished
|
|
request = make_request("GET", "http://store-cache/")
|
|
cached_response(request)
|
|
response = store.get(request)
|
|
assert response.finished?
|
|
end
|
|
|
|
private
|
|
|
|
def init_store
|
|
tmpdir = Pathname.new(Dir.tmpdir).join(SecureRandom.alphanumeric)
|
|
FileUtils.mkdir_p(tmpdir)
|
|
HTTPX::Plugins::ResponseCache::FileStore.new(tmpdir)
|
|
end
|
|
end
|