From 19e15f7b029b3c3c5e9eeed948a37e2316ed5975 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Thu, 18 Dec 2008 19:30:35 -0800 Subject: [PATCH] MogileFS::Mysql: list_keys returns nil if nothing was found This is to be compatible with MogileFS::MogileFS --- lib/mogilefs/mysql.rb | 3 ++- test/test_mysql.rb | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/mogilefs/mysql.rb b/lib/mogilefs/mysql.rb index c8a35e0..67432ed 100644 --- a/lib/mogilefs/mysql.rb +++ b/lib/mogilefs/mysql.rb @@ -60,7 +60,8 @@ class MogileFS::Mysql yield(dkey, length, devcount) if block_given? keys << dkey end - [ keys, (keys.last || '') ] + + keys.empty? ? nil : [ keys, (keys.last || '') ] end ## diff --git a/test/test_mysql.rb b/test/test_mysql.rb index 822916f..872f05f 100644 --- a/test/test_mysql.rb +++ b/test/test_mysql.rb @@ -119,6 +119,11 @@ class TestMogileFS__Mysql < Test::Unit::TestCase assert_equal expect_full, full end + def test_list_keys_empty + @my.expect << [] + assert_nil @mg.list_keys + end + def test_size @my.expect << [ [ '123' ] ] assert_equal 123, @mg.size('foo') -- 2.11.4.GIT