transform_exceptions
);
+has hostname_file => (is => 'ro', default => sub {'/etc/hostname' });
+
sub gather {
my ($self) = @_;
return transform_exceptions {
sub _gather_hostname {
my ($self) = @_;
- my $hostname = output_from_file '/etc/hostname';
+ my $hostname = output_from_file $self->hostname_file;
chomp $hostname;
$hostname =~ s{(?:^\s+|\s+$)}{}g;
return $hostname;
use strictures 1;
use Test::More;
+use FindBin;
use System::Introspector::Probe::Host;
-my $probe = System::Introspector::Probe::Host->new;
-my $data = $probe->gather;
+my $probe = System::Introspector::Probe::Host->new(
+ hostname_file => "$FindBin::Bin/data/hostname",
+);
+my $data = $probe->gather;
ok length($data->{hostname}), 'found a hostname';
ok defined($data->{uname}{ $_ }), "has uname $_" for qw(