diff options
author | Eric Wong <e@80x24.org> | 2022-01-24 08:43:55 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2022-01-24 11:26:28 +0000 |
commit | 6cc0ae1f3e365015fe219703ccab77b19db4705b (patch) | |
tree | e2e29b65f488a26ac5b895499f6ef7c46d1013ae /test/test_mcache.rb | |
parent | 9183c38754d76fcd778965350046738557d13722 (diff) | |
download | dtas-6cc0ae1f3e365015fe219703ccab77b19db4705b.tar.gz |
We still need the TTL to deal with fuse.sshfs and maybe other weird FSes which don't return the st_ctime properly.
Diffstat (limited to 'test/test_mcache.rb')
-rw-r--r-- | test/test_mcache.rb | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/test/test_mcache.rb b/test/test_mcache.rb index 2bf0e98..983a69e 100644 --- a/test/test_mcache.rb +++ b/test/test_mcache.rb @@ -1,19 +1,29 @@ -# Copyright (C) 2016-2020 all contributors <dtas-all@nongnu.org> +# Copyright (C) all contributors <dtas-all@nongnu.org> # License: GPL-3.0+ <https://www.gnu.org/licenses/gpl-3.0.txt> # frozen_string_literal: true require './test/helper' require 'dtas/mcache' +require 'tempfile' class TestMcache < Testcase def test_mcache + tmp = Tempfile.new(%W(tmp .sox)) + fn = tmp.path + cmd = %W(sox -r 44100 -b 16 -c 2 -n #{fn} trim 0 1) + system(*cmd) or skip mc = DTAS::Mcache.new exist = nil - mc.lookup('hello') { |infile, hash| exist = hash } + mc.lookup(fn) { |infile, hash| + hash[:ctime] = File.stat(infile).ctime + exist = hash + } assert_kind_of Hash, exist - assert_equal 'hello', exist[:infile] + assert_equal fn, exist[:infile] assert_operator exist[:btime], :<=, DTAS.now - assert_same exist, mc.lookup('hello') + assert_same exist, mc.lookup(fn) assert_nil mc.lookup('HELLO') - assert_same exist, mc.lookup('hello'), 'no change after miss' + assert_same exist, mc.lookup(fn), 'no change after miss' + ensure + tmp.close! end end |