3 # Copyright (C) 2007 by Levi Bard
5 # This program is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU Lesser General Public License
7 # as published by the Free Software Foundation; either version 2
8 # of the License, or (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU Lesser General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 # @author Levi Bard <taktaktaktaktaktaktaktaktaktak@gmail.com>
23 require 'lightmediascanner'
28 class LightMediaScanner::Test < Test::Unit::TestCase
29 include LightMediaScanner
32 assert(LightMediaScanner::constants.include?('Scanner'))
33 assert(LightMediaScanner::constants.include?('Parser'))
36 def test_scanner_gooddata()
42 assert_nothing_raised(){ lms = Scanner.new(dbPath) }
43 assert_equal(dbPath, lms.db_path)
46 assert_equal(lms.timeout, timeout)
48 assert(!lms.processing?)
50 lms.commit_interval = commitInterval
51 assert_equal(lms.commit_interval, commitInterval)
53 assert_raise(RuntimeError){ lms.process('/') }
54 assert_raise(RuntimeError){ lms.check('/') }
55 assert_nothing_raised(){ lms.add_charset('ISO-8859-1') }
56 assert_nothing_raised(){ lms.remove_charset('ISO-8859-1') }
57 assert_raise(RuntimeError){ Parser.new(lms, 'blah') }
60 def test_scanner_baddata()
66 assert_raise(TypeError){ lms = Scanner.new(nil) }
67 assert_nothing_raised(){ lms = Scanner.new(dbPath) }
68 assert_equal(dbPath, lms.db_path)
70 assert_raise(TypeError){ lms.timeout = 'Jared' }
71 assert_raise(TypeError){ lms.timeout = 3.14159 }
73 assert_raise(TypeError){ lms.commit_interval = 2.72 }
74 assert_raise(TypeError){ lms.commit_interval = nil }
76 assert_raise(TypeError){ lms.process(nil) }
77 assert_raise(TypeError){ lms.process(3) }
79 assert_raise(TypeError){ lms.check(lms) }
80 assert_raise(TypeError){ lms.check(5.43) }
82 assert_raise(TypeError){ lms.add_charset(nil) }
83 assert_raise(TypeError){ lms.add_charset(42) }
84 assert_raise(RuntimeError){ lms.add_charset('I CAN HAZ CHARSET?') }
86 assert_raise(RuntimeError){ lms.remove_charset('EBCDIC') }
87 assert_raise(TypeError){ lms.remove_charset(nil) }