removed process groups from the connection class child cleanup logic
[scpubgit/Object-Remote.git] / t / transfer.t
CommitLineData
6ed5d580 1use strictures 1;
2use Test::More;
3use Test::Fatal;
ed5a8a8e 4use FindBin;
6ed5d580 5
abef6e5b 6$ENV{OBJECT_REMOTE_TEST_LOGGER} = 1;
f129bfaf 7
6ed5d580 8$ENV{PERL5LIB} = join(
9 ':', ($ENV{PERL5LIB} ? $ENV{PERL5LIB} : ()), qw(lib t/lib)
10);
11
12use Object::Remote;
13
14my $strA = 'foo';
15my $strB = 'bar';
16
17is exception {
18 my $proxy = ORTestTransfer->new::on('-', value => \$strA);
19 is_deeply $proxy->value, \$strA, 'correct value after construction';
ed5a8a8e 20}, undef, 'scalar refs - no errors during construction';
6ed5d580 21
22is exception {
23 my $proxy = ORTestTransfer->new::on('-');
24 $proxy->value(\$strB);
25 is_deeply $proxy->value, \$strB, 'correct value after construction';
ed5a8a8e 26}, undef, 'scalar refs - no errors during attribute set';
27
28my $data_file = "$FindBin::Bin/data/numbers.txt";
29
30is exception {
31 my $out = '';
32 open my $fh, '>', \$out or die "Unable to open in-memory file: $!\n";
33 my $proxy = ORTestGlobs->new::on('-', handle => $fh);
34 ok $proxy->handle, 'filehandle was set';
35 ok $proxy->write('foo'), 'write was successful';
36 is $out, 'foo', 'write reached target';
37}, undef, 'filehandles - no error during construction';
38
39is exception {
40 my $proxy = ORTestGlobs->new::on('-');
41 my $handle = $proxy->gethandle;
42 print $handle 'foo';
43 is $proxy->getvalue, 'foo', 'correct value written';
44 $handle->autoflush(1);
45}, undef, 'filehandles - no error during remote handle';
46
47is exception {
48 my $proxy = ORTestGlobs->new::on('-');
49 my $rhandle = $proxy->getreadhandle($data_file);
50 my @lines = <$rhandle>;
51 chomp @lines;
52 is_deeply \@lines, [1 .. 5], 'reading back out of the handle';
53}, undef, 'filehandles - no error during remote read';
54
55is exception {
56 my $proxy = ORTestGlobs->new::on('-');
57 my $rhandle = $proxy->getreadhandle($data_file);
58 binmode $rhandle;
59}, undef, 'filehandles - no errors during binmode';
6ed5d580 60
61done_testing;