Debian Codegraph @

t/unit/App/Yath/Plugin/SysInfo.t

raw
1 use Test2::V0 -target => 'App::Yath::Plugin::SysInfo';
2 use Test2::Util qw/CAN_THREAD CAN_REALLY_FORK CAN_FORK CAN_SIGSYS/;
3 # HARNESS-DURATION-SHORT
4
5 my $control = mock $CLASS => (
6 override => [
7 hostname => sub { 'foo.bar.baz-22.superlongnamewedonotwantseen.evenlonger.holycow.net' },
8 ],
9 );
10
11 local *App::Yath::Plugin::SysInfo::Config = {
12 'useperlio' => 'define',
13 'use64bitint' => 'define',
14 'use64bitall' => 'define',
15 'useithreads' => 'define',
16 'osname' => 'linux',
17 'archname' => 'x86_64-linux',
18 'usemultiplicity' => undef,
19 'version' => '1.2.3',
20 'uselongdouble' => undef,
21 };
22
23 local $ENV{USER} = 'bob';
24 local $ENV{SHELL} = '/bin/shell';
25 local $ENV{TERM} = 'myterm';
26
27 my $meta = {};
28 my $fields = [];
29
30 my $one = $CLASS->new();
31 $one->inject_run_data(meta => $meta, fields => $fields);
32
33 is(
34 $fields,
35 [
36 {
37 name => 'sys',
38 details => 'foo.bar.baz-22',
39 raw => 'foo.bar.baz-22.superlongnamewedonotwantseen.evenlonger.holycow.net',
40
41 data => {
42 hostname => 'foo.bar.baz-22.superlongnamewedonotwantseen.evenlonger.holycow.net',
43 ipc => {
44 can_fork => CAN_FORK(),
45 can_really_fork => CAN_REALLY_FORK(),
46 can_sigsys => CAN_SIGSYS(),
47 can_thread => CAN_THREAD(),
48 },
49 env => {
50 shell => '/bin/shell',
51 term => 'myterm',
52 user => 'bob',
53 },
54 config => {
55 archname => 'x86_64-linux',
56 osname => 'linux',
57 use64bitall => 'define',
58 use64bitint => 'define',
59 useithreads => 'define',
60 uselongdouble => undef,
61 usemultiplicity => undef,
62 useperlio => 'define',
63 version => '1.2.3',
64 }
65 },
66 }
67
68 ],
69 "Got expected fields"
70 );
71
72 $meta = {};
73 $fields = [];
74 $one = $CLASS->new(host_short_pattern => "bar\\.baz-\\d+");
75 $one->inject_run_data(meta => $meta, fields => $fields);
76
77 is(
78 $fields,
79 [
80 {
81 name => 'sys',
82 details => 'bar.baz-22',
83 raw => 'foo.bar.baz-22.superlongnamewedonotwantseen.evenlonger.holycow.net',
84
85 data => {
86 hostname => 'foo.bar.baz-22.superlongnamewedonotwantseen.evenlonger.holycow.net',
87 ipc => {
88 can_fork => CAN_FORK(),
89 can_really_fork => CAN_REALLY_FORK(),
90 can_sigsys => CAN_SIGSYS(),
91 can_thread => CAN_THREAD(),
92 },
93 env => {
94 shell => '/bin/shell',
95 term => 'myterm',
96 user => 'bob',
97 },
98 config => {
99 archname => 'x86_64-linux',
100 osname => 'linux',
101 use64bitall => 'define',
102 use64bitint => 'define',
103 useithreads => 'define',
104 uselongdouble => undef,
105 usemultiplicity => undef,
106 useperlio => 'define',
107 version => '1.2.3',
108 }
109 },
110 }
111
112 ],
113 "Got expected fields, including custom hostname short filter"
114 );
115
116 done_testing;