1 # Copyright (c) 2009-2012 Zmanda, Inc. All Rights Reserved.
3 # This program is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU General Public License
5 # as published by the Free Software Foundation; either version 2
6 # of the License, or (at your option) any later version.
8 # This program is distributed in the hope that it will be useful, but
9 # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
10 # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 # You should have received a copy of the GNU General Public License along
14 # with this program; if not, write to the Free Software Foundation, Inc.,
15 # 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 # Contact information: Zmanda Inc, 465 S. Mathilda Ave., Suite 300
18 # Sunnyvale, CA 94086, USA, or: http://www.zmanda.com
20 use Test::More tests => 5;
25 use lib "@amperldir@";
26 use Installcheck::Config;
27 use Installcheck::Changer;
32 use Amanda::Config qw( :init :getconf config_dir_relative );
35 # set up debugging so debug output doesn't interfere with test results
36 Amanda::Debug::dbopen("installcheck");
37 Installcheck::log_test_output();
39 # and disable Debug's die() and warn() overrides
40 Amanda::Debug::disable_die_override();
42 my $testconf = Installcheck::Config->new();
45 my $cfg_result = config_init($CONFIG_INIT_EXPLICIT_NAME, 'TESTCONF');
46 if ($cfg_result != $CFGERR_OK) {
47 my ($level, @errors) = Amanda::Config::config_errors();
48 die(join "\n", @errors);
51 my $chg = Amanda::Changer->new("chg-null:");
52 is($chg->have_inventory(), '', "changer have inventory");
54 my ($get_info, $check_info, $do_load, $got_res);
56 $get_info = make_cb('get_info' => sub {
57 $chg->info(info_cb => $check_info, info => [ 'num_slots', 'fast_search' ]);
60 $check_info = make_cb('check_info' => sub {
63 die($err) if defined($err);
65 is_deeply({ %results },
66 { num_slots => 1, fast_search => 1 },
67 "info() returns the correct num_slots and fast_search");
72 $do_load = make_cb('do_load' => sub {
73 $chg->load(relative_slot => "current",
77 $got_res = make_cb('got_res' => sub {
79 ok(!$err, "no error loading relative slot 'current'")
81 is($res->{'device'}->device_name, 'null:',
82 "returns correct device name");
84 $res->release(finished_cb => sub {
85 Amanda::MainLoop::quit();
91 Amanda::MainLoop::run();
94 # eject is not implemented
96 my $try_eject = make_cb('try_eject' => sub {
97 $chg->eject(finished_cb => sub {
100 { type => 'failed', reason => 'notimpl' },
101 "eject returns a failed/notimpl error");
103 Amanda::MainLoop::quit();
108 Amanda::MainLoop::run();