dtas.git  about / heads / tags
duct tape audio suite for *nix
blob 983a69e161493d0d5613eca1eefa15f12dca425d 825 bytes (raw)
$ git show HEAD:test/test_mcache.rb	# shows this blob on the CLI

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
 
# 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(fn) { |infile, hash|
      hash[:ctime] = File.stat(infile).ctime
      exist = hash
    }
    assert_kind_of Hash, exist
    assert_equal fn, exist[:infile]
    assert_operator exist[:btime], :<=, DTAS.now
    assert_same exist, mc.lookup(fn)
    assert_nil mc.lookup('HELLO')
    assert_same exist, mc.lookup(fn), 'no change after miss'
  ensure
    tmp.close!
  end
end

git clone git://80x24.org/dtas.git
git clone https://80x24.org/dtas.git