1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107
|
# systemd tests for user
use strict;
use warnings;
# list of tests.
my @tests = (
{
name => 'basic-service',
backend_arg => 'gmail',
file_contents_unlike => {
"home/joe/.config/systemd/user/gmail-imap-tunnel@.service"
=> qr/disable/ ,
},
},
{
name => 'basic-socket',
backend_arg => 'gmail',
file_contents_unlike => {
"home/joe/.config/systemd/user/gmail-imap-tunnel.socket"
=> qr/disable/ ,
}
},
{
name => 'override-service',
backend_arg => 'obex',
setup => {
'main-obex' => '/usr/lib/systemd/user/obex.service',
},
load => 'service:obex Service Environment:0="TEST=true"',
file_contents_like => {
"home/joe/.config/systemd/user/obex.service.d/override.conf" => qr/TEST=true/ ,
},
file_check_sub => sub {
my $list_ref = shift ;
# file added during tests
push @$list_ref, "/home/joe/.config/systemd/user/obex.service.d/override.conf" ;
}
},
{
name => 'overridden-service',
backend_arg => 'obex',
data_from => 'override-service',
setup => {
'main-obex' => '/usr/lib/systemd/user/obex.service',
'user-obex' => '~/.config/systemd/user/obex.service.d/override.conf',
},
check => [
'service:obex Unit Description' => 'Le service Obex a la dent bleue',
'service:obex Unit Description' => {
mode => 'user',
value => 'Le service Obex a la dent bleue'
},
'service:obex Unit Description' => {
mode => 'layered',
value => 'Bluetooth OBEX service'
},
]
},
{
name => 'delete-service',
backend_arg => 'obex.service',
setup => {
'main-obex' => '/usr/lib/systemd/user/obex.service',
'user-obex' => '~/.config/systemd/user/obex.service.d/override.conf',
},
load => 'service:obex Unit Description~',
check => [
'service:obex Unit Description' => {
mode => 'user',
value => 'Bluetooth OBEX service'
},
],
file_check_sub => sub {
my $list_ref = shift ;
# file added during tests
@$list_ref = grep { /usr/ } @$list_ref ;
}
},
{
name => 'from-scratch',
backend_arg => 'test.service',
load => 'service:test Unit Description="test from scratch"',
file_contents_like => {
"home/joe/.config/systemd/user/test.service" => qr/from scratch/ ,
},
},
{
name => 'duplicity',
backend_arg => 'duplicity',
check => [
'service:duplicity Service ExecStart:0' => "my-backup",
'timer:duplicity Timer OnCalendar:0' => '13:00',
'timer:duplicity Unit Description'=>"Run duplicity",
]
}
);
return {
tests => \@tests,
home_for_test=>'/home/joe',
conf_dir => '~/.config/systemd/user/',
config_file_name => 'systemd-user',
}
|