aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAngelo Naselli <anaselli@linux.it>2015-03-25 17:08:20 +0100
committerAngelo Naselli <anaselli@linux.it>2015-03-25 17:08:20 +0100
commit708eb6dcf2e4e7602250a35ba7552ddad8a72419 (patch)
treeeefa43d30c0f0f87d258afeedc4a85d199a3a540
parent143675198e9c0fcef3335affa224c6b9799a9a6b (diff)
downloadcolin-keep-708eb6dcf2e4e7602250a35ba7552ddad8a72419.tar
colin-keep-708eb6dcf2e4e7602250a35ba7552ddad8a72419.tar.gz
colin-keep-708eb6dcf2e4e7602250a35ba7552ddad8a72419.tar.bz2
colin-keep-708eb6dcf2e4e7602250a35ba7552ddad8a72419.tar.xz
colin-keep-708eb6dcf2e4e7602250a35ba7552ddad8a72419.zip
added include_static_services property and its test
-rw-r--r--lib/ManaTools/Shared/Services.pm20
-rw-r--r--t/07-Shared_Services.t23
2 files changed, 42 insertions, 1 deletions
diff --git a/lib/ManaTools/Shared/Services.pm b/lib/ManaTools/Shared/Services.pm
index abef8c3..c0f06c5 100644
--- a/lib/ManaTools/Shared/Services.pm
+++ b/lib/ManaTools/Shared/Services.pm
@@ -114,7 +114,25 @@ sub _dbusObjectInitialize {
$self->dbus_systemd1_object($self->dbus_systemd1_service->get_object("/org/freedesktop/systemd1"));
}
+has 'include_static_services' => (
+ is => 'rw',
+ isa => 'Bool',
+ default => 0
+);
+
+#=============================================================
+
+=head2 attributes
+=head3 service_info
+
+ A HashRef collecting all the service information.
+ if include_static_services (default is false) is set also static
+ services are included.
+
+=cut
+
+#=============================================================
has 'service_info' => (
is => 'rw',
traits => ['Hash'],
@@ -149,7 +167,7 @@ sub _serviceInfoInitialization {
$st = 'enabled';
}
}
- if ($st && $st ne 'static') {
+ if ($st && ($self->include_static_services() || $st ne 'static')) {
$services{$name} = {
'name' => $s->[0],
'description' => $s->[1],
diff --git a/t/07-Shared_Services.t b/t/07-Shared_Services.t
new file mode 100644
index 0000000..680466a
--- /dev/null
+++ b/t/07-Shared_Services.t
@@ -0,0 +1,23 @@
+use 5.006;
+use strict;
+use warnings FATAL => 'all';
+use Test::More;
+use Data::Dumper;
+use Time::Piece;
+
+BEGIN {
+ use_ok( 'ManaTools::Shared::Services' ) || print "ManaTools::Shared::Services failed!\n";
+}
+
+ ok(my $s = ManaTools::Shared::Services->new(), 'create ManaTools::Shared::Services');
+ is ($s->include_static_services(), 0, 'include_static_services (false)');
+ ok(my $services = $s->service_info(), 'service_info');
+ diag Dumper($services);
+
+ # Get static services also
+ ok($s = ManaTools::Shared::Services->new(include_static_services => 1), 'create ManaTools::Shared::Services with static services');
+ is ($s->include_static_services(), 1, 'include_static_services (true)');
+ ok($services = $s->service_info(), 'service_info with static services');
+ diag Dumper($services);
+
+done_testing;