e-smith-test/root/etc/e-smith/events/actions/testing-conf

73 lines
2.2 KiB
Plaintext
Raw Permalink Normal View History

#!/usr/bin/perl -w
#----------------------------------------------------------------------
# Copyright 1999-2003 Mitel Networks Corporation
# This program is free software; you can redistribute it and/or
# modify it under the same terms as Perl itself.
#----------------------------------------------------------------------
=head1 NAME
testing-conf -- configure testing service
=head1 DESCRIPTION
This action sets up the testing service when you first install
e-smith-test, setting the "destruction" property to 0 (non-destructive).
It is a no-op if the "destruction" property is already defined.
=begin testing
use esmith::ConfigDB;
$ENV{ESMITH_CONFIG_DB} = "00e-smith-test/configuration";
unlink $ENV{ESMITH_CONFIG_DB};
ok(my $conf = esmith::ConfigDB->create(), "Create new config file");
ok(my $test_service = $conf->new_record('testing', {type => 'service'}),
"Create new record for testing service");
isa_ok($test_service, 'esmith::DB::Record');
ok(not(defined($test_service->prop('destruction'))),
"Testing should be absent before we run");
is(system("$^X $Original_File"), 0, "System command returned 0");
$conf = esmith::ConfigDB->open();
$test_service = $conf->get('testing');
ok(defined($test_service->prop('destruction')), "Destruction is now defined");
$test_service->set_prop('destruction', 1);
is(system("$^X $Original_File"), 0, "System command returned 0");
$conf = esmith::ConfigDB->open();
$test_service = $conf->get('testing');
is($test_service->prop('destruction'), 1,
"Destruction is left alone if already defined");
$test_service->set_prop('destruction', 0);
is(system("$^X $Original_File"), 0, "System command returned 0");
$conf = esmith::ConfigDB->open();
$test_service = $conf->get('testing');
is($test_service->prop('destruction'), 0,
"Destruction is left alone if already defined, even if 0");
=end testing
=cut
use strict;
use esmith::ConfigDB;
my $conf = esmith::ConfigDB->open()
or die "Configuration database does not exist";
if (my $test_service = $conf->get('testing')
|| $conf->new_record('testing', { type => 'service'} ))
{
unless (defined $test_service->prop('destruction'))
{
$test_service->set_prop('destruction', 0);
}
}
exit 0;