File: write.t

package info (click to toggle)
liblinux-systemd-perl 1.201600-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 284 kB
  • sloc: perl: 640; makefile: 7
file content (99 lines) | stat: -rw-r--r-- 2,465 bytes parent folder | download
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
use Test::More;
use Linux::Systemd::Journal::Write;

my $jnl = new_ok 'Linux::Systemd::Journal::Write' => [id => 'test'];

ok $jnl->print('flarg'), 'print string';

# {
#     "PRIORITY" : "6",
#     "SYSLOG_IDENTIFIER" : "perl",
#     "MESSAGE" : "flarg",
# }

ok $jnl->print('Hello world', 4), 'print with priority';

# {
#     "PRIORITY" : "4",
#     "SYSLOG_IDENTIFIER" : "perl",
#     "MESSAGE" : "Hello world",
# }

ok $jnl->perror('An error was set'), 'perror';

# {
#     "PRIORITY" : "3",
#     "SYSLOG_IDENTIFIER" : "perl",
#     "ERRNO" : "0",
#     "MESSAGE" : "An error was set: Success",
# }

my $hashref = {
    message        => 'Test send a hashref',
    abstract       => 'XS wrapper around sd-journal',
    author         => 'Ioan Rogers <ioanr@cpan.org>',
    dynamic_config => 0,
};

ok $jnl->send($hashref), 'send a hashref';

# {
#     "PRIORITY" : "6",
#     "DYNAMIC_CONFIG" : "0",
#     "AUTHOR" : "Ioan Rogers <ioanr@cpan.org>",
#     "CODE_LINE" : "35",
#     "MESSAGE" : "Test send a hashref",
#     "ABSTRACT" : "XS wrapper around sd-journal",
#     "CODE_FILE" : "t/01-main.t",
#     "SYSLOG_IDENTIFIER" : "01-main.t",
# }

my $arrayref = [
    message        => 'Test send an arrayref',
    abstract       => 'XS wrapper around sd-journal',
    author         => 'Ioan Rogers <ioanr@cpan.org>',
    dynamic_config => 0,
];
ok $jnl->send($arrayref), 'send an arrayref';

# {
#     "PRIORITY" : "6",
#     "DYNAMIC_CONFIG" : "0",
#     "AUTHOR" : "Ioan Rogers <ioanr@cpan.org>",
#     "ABSTRACT" : "XS wrapper around sd-journal",
#     "CODE_FILE" : "t/01-main.t",
#     "SYSLOG_IDENTIFIER" : "01-main.t",
#     "MESSAGE" : "Test send an arrayref",
#     "CODE_LINE" : "47",
# }

ok $jnl->send(
    message        => 'Test send an array',
    abstract       => 'XS wrapper around sd-journal',
    author         => 'Ioan Rogers <ioanr@cpan.org>',
    dynamic_config => 0,
  ),
  'send an array';

# {
#     "PRIORITY" : "6",
#     "DYNAMIC_CONFIG" : "0",
#     "AUTHOR" : "Ioan Rogers <ioanr@cpan.org>",
#     "ABSTRACT" : "XS wrapper around sd-journal",
#     "CODE_FILE" : "t/01-main.t",
#     "SYSLOG_IDENTIFIER" : "01-main.t",
#     "MESSAGE" : "Test send an array",
#     "CODE_LINE" : "65",
# }

ok $jnl->send('I am a string'), 'send a string';

# {
#     "PRIORITY" : "6",
#     "CODE_FILE" : "t/01-main.t",
#     "SYSLOG_IDENTIFIER" : "01-main.t",
#     "MESSAGE" : "I am a string",
#     "CODE_LINE" : "83",
# }

done_testing;