|
@@ -63,15 +63,14 @@ subtest "_build_classes" => sub {
|
|
|
|
|
|
|
|
subtest "_check_node" => sub {
|
|
subtest "_check_node" => sub {
|
|
|
my $which = Test::MockModule->new('File::Which');
|
|
my $which = Test::MockModule->new('File::Which');
|
|
|
- $which->redefine('which', sub { "$path2here/../bin/playwright_server" });
|
|
|
|
|
|
|
|
|
|
- my $bin = Test::MockFile->file("$path2here/../bin/playwright_server");
|
|
|
|
|
- like( dies { Playwright::_check_node() }, qr/server in/i, "Server not existing throws");
|
|
|
|
|
|
|
+ my %to_return = (
|
|
|
|
|
+ node => '/bogus',
|
|
|
|
|
+ npm => '/hokum',
|
|
|
|
|
+ playwright_server => "$path2here/../bin/playwright_server",
|
|
|
|
|
+ );
|
|
|
|
|
|
|
|
- undef $bin;
|
|
|
|
|
- $bin = Test::MockFile->file("$path2here/../bin/playwright_server",'');
|
|
|
|
|
-
|
|
|
|
|
- $which->redefine('which', sub { shift eq 'node' ? '/bogus' : '/hokum' });
|
|
|
|
|
|
|
+ $which->redefine('which', sub { my $to = shift; $to_return{$to} } );
|
|
|
my $node = Test::MockFile->file('/bogus', undef, { mode => 0777 } );
|
|
my $node = Test::MockFile->file('/bogus', undef, { mode => 0777 } );
|
|
|
my $npm = Test::MockFile->file('/hokum', undef, { mode => 0777 } );
|
|
my $npm = Test::MockFile->file('/hokum', undef, { mode => 0777 } );
|
|
|
|
|
|
|
@@ -79,6 +78,12 @@ subtest "_check_node" => sub {
|
|
|
undef $node;
|
|
undef $node;
|
|
|
$node = Test::MockFile->file('/bogus', '', { mode => 0777 } );
|
|
$node = Test::MockFile->file('/bogus', '', { mode => 0777 } );
|
|
|
|
|
|
|
|
|
|
+ my $bin = Test::MockFile->file("$path2here/../bin/playwright_server");
|
|
|
|
|
+ like( dies { Playwright::_check_node() }, qr/server in/i, "Server not existing throws");
|
|
|
|
|
+
|
|
|
|
|
+ undef $bin;
|
|
|
|
|
+ $bin = Test::MockFile->file("$path2here/../bin/playwright_server",'');
|
|
|
|
|
+
|
|
|
like( dies { Playwright::_check_node() }, qr/npm must exist/i, "npm not existing throws");
|
|
like( dies { Playwright::_check_node() }, qr/npm must exist/i, "npm not existing throws");
|
|
|
undef $npm;
|
|
undef $npm;
|
|
|
$npm = Test::MockFile->file('/hokum', '', { mode => 0777 } );
|
|
$npm = Test::MockFile->file('/hokum', '', { mode => 0777 } );
|
|
@@ -89,38 +94,6 @@ subtest "_check_node" => sub {
|
|
|
my $pmock = Test::MockModule->new('File::pushd');
|
|
my $pmock = Test::MockModule->new('File::pushd');
|
|
|
$pmock->redefine('pushd', sub {shift});
|
|
$pmock->redefine('pushd', sub {shift});
|
|
|
|
|
|
|
|
- $qxret = '';
|
|
|
|
|
- like( dies { Playwright::_check_node() }, qr/could not list/i, "package.json not existing throws");
|
|
|
|
|
-
|
|
|
|
|
- $qxret = '{
|
|
|
|
|
- "name": "playwright-server-perl",
|
|
|
|
|
- "version": "1.0.0",
|
|
|
|
|
- "problems": [
|
|
|
|
|
- "missing: express@^4.17, required by playwright-server-perl@1.0.0",
|
|
|
|
|
- "missing: playwright@^1.5, required by playwright-server-perl@1.0.0",
|
|
|
|
|
- "missing: yargs@^16.1, required by playwright-server-perl@1.0.0",
|
|
|
|
|
- "missing: uuid@^8.3, required by playwright-server-perl@1.0.0"
|
|
|
|
|
- ],
|
|
|
|
|
- "dependencies": {
|
|
|
|
|
- "express": {
|
|
|
|
|
- "required": "^4.17",
|
|
|
|
|
- "missing": true
|
|
|
|
|
- },
|
|
|
|
|
- "playwright": {
|
|
|
|
|
- "required": "^1.5",
|
|
|
|
|
- "missing": true
|
|
|
|
|
- },
|
|
|
|
|
- "yargs": {
|
|
|
|
|
- "required": "^16.1",
|
|
|
|
|
- "missing": true
|
|
|
|
|
- },
|
|
|
|
|
- "uuid": {
|
|
|
|
|
- "required": "^8.3",
|
|
|
|
|
- "missing": true
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }';
|
|
|
|
|
-
|
|
|
|
|
#XXX doesn't look like we can mock $? correctly
|
|
#XXX doesn't look like we can mock $? correctly
|
|
|
#like( dies { Playwright::_check_node($path2here, $decoder) }, qr/installing node/i, "npm failure throws");
|
|
#like( dies { Playwright::_check_node($path2here, $decoder) }, qr/installing node/i, "npm failure throws");
|
|
|
$fakecapture->redefine('capture_stderr', sub { 'package-lock' });
|
|
$fakecapture->redefine('capture_stderr', sub { 'package-lock' });
|
|
@@ -148,9 +121,10 @@ subtest "new" => sub {
|
|
|
parent => $$,
|
|
parent => $$,
|
|
|
pid => 666,
|
|
pid => 666,
|
|
|
port => 420,
|
|
port => 420,
|
|
|
|
|
+ timeout => 5,
|
|
|
}, 'Playwright');
|
|
}, 'Playwright');
|
|
|
|
|
|
|
|
- is(Playwright->new( ua => 'whee', debug => 1), $expected, "Constructor functions as expected");
|
|
|
|
|
|
|
+ is(Playwright->new( timeout => 5, ua => 'whee', debug => 1), $expected, "Constructor functions as expected");
|
|
|
|
|
|
|
|
$expected = bless({
|
|
$expected = bless({
|
|
|
ua => bless({},'LWP::UserAgent'),
|
|
ua => bless({},'LWP::UserAgent'),
|
|
@@ -158,6 +132,7 @@ subtest "new" => sub {
|
|
|
parent => $$,
|
|
parent => $$,
|
|
|
pid => 666,
|
|
pid => 666,
|
|
|
port => 420,
|
|
port => 420,
|
|
|
|
|
+ timeout => 30,
|
|
|
}, 'Playwright');
|
|
}, 'Playwright');
|
|
|
|
|
|
|
|
is(Playwright->new(), $expected, "Constructor defaults expected");
|
|
is(Playwright->new(), $expected, "Constructor defaults expected");
|