test/test_tree_wallets.rb in zold-0.20.1 vs test/test_tree_wallets.rb in zold-0.20.2
- old
+ new
@@ -21,10 +21,11 @@
# SOFTWARE.
require 'minitest/autorun'
require 'tmpdir'
require_relative 'test__helper'
+require_relative '../lib/zold/wallet'
require_relative '../lib/zold/key'
require_relative '../lib/zold/id'
require_relative '../lib/zold/tree_wallets'
# TreeWallets test.
@@ -57,17 +58,26 @@
assert_equal(10, wallets.all.count)
end
end
def test_count_tree_wallets
+ files = [
+ "0000111122223333#{Zold::Wallet::EXT}",
+ "a/b/d/e/0000111122223333#{Zold::Wallet::EXT}",
+ "a/b/0000111122223333#{Zold::Wallet::EXT}"
+ ]
+ garbage = [
+ '0000111122223333',
+ '0000111122223333.lock',
+ 'a/b/c-0000111122223333'
+ ]
Dir.mktmpdir do |dir|
- Dir.chdir(dir) do
- 5.times { |i| FileUtils.touch("wallet_#{i}.z") }
- Dir.mktmpdir(nil, dir) do |subdir|
- 5.times { |i| FileUtils.touch("#{subdir}/wallet_#{i}.z") }
- wallets = Zold::TreeWallets.new(Dir.pwd)
- assert_equal(10, wallets.count)
- end
+ (files + garbage).each do |f|
+ path = File.join(dir, f)
+ FileUtils.mkdir_p(File.dirname(path))
+ FileUtils.touch(path)
end
+ wallets = Zold::TreeWallets.new(dir)
+ assert_equal(files.count, wallets.count)
end
end
end