allow usage of a pool of mediawiki updaters instead of just single-process
[scpubgit/System-Introspector-Report.git] / t / publish_mediawiki.t
index a328e8e..1731bdf 100644 (file)
@@ -2,38 +2,20 @@ use strictures 1;
 use Test::More;
 use IO::All;
 use FindBin;
-
+use File::Temp;
+use lib "$FindBin::Bin/lib";
 use aliased 'System::Introspector::Report::Publish::MediaWiki';
 
-my %result;
-
-do {
-  package TestConnection;
-  use Moo;
-  use IO::All;
-  use aliased 'System::Introspector::Report::Publish::MediaWiki::Page';
+$ENV{TEST_SI_REPORT_OUT} = my $out_dir = File::Temp->newdir;
+$ENV{TEST_SI_REPORT_IN}  = "$FindBin::Bin/data";
 
-  sub get {
-    my ($self, $name) = @_;
-    return Page->new(
-      name      => $name,
-      timestamp => 23,
-      content   => scalar(io("$FindBin::Bin/data/$name.txt")->slurp),
-    );
-  }
-
-  sub put {
-    my ($self, $page) = @_;
-    $result{$page->name} = $page->content;
-  }
-};
+my %result;
 
-my $conn = TestConnection->new;
 my $wiki = MediaWiki->new(
   api_uri => 'http://example.com:9999/',
+  connection_class => 'TestConnection',
   username => 'foo',
   password => 'bar',
-  connection => $conn,
   page => {
     foo => {
       report => ['foo:*'],
@@ -89,9 +71,9 @@ my $_despace = sub {
 };
 
 ## uncomment to regenerate result file
-# do { no warnings; $result{foo} > io("$FindBin::Bin/data/result/foo.txt") };
+# do { no warnings; io("$out_dir/foo") > io("$FindBin::Bin/data/result/foo.txt"); fail "regenerated" };
 
-is $result{foo}->$_despace,
+is scalar(io("$out_dir/foo")->slurp)->$_despace,
    scalar(io("$FindBin::Bin/data/result/foo.txt")->slurp)->$_despace,
    'resulting page looks correct';