diff options
author | Eric Wong (Contractor, The Linux Foundation) <e@80x24.org> | 2018-02-28 22:29:38 +0000 |
---|---|---|
committer | Eric Wong (Contractor, The Linux Foundation) <e@80x24.org> | 2018-02-28 23:06:20 +0000 |
commit | aae578aad0fd1c7b788a461fa29cb70f0a29fb02 (patch) | |
tree | 1c658e8cace98ae2b9fd5d1a6eadc530b59d04c1 /t | |
parent | ee8927c99ae68cbcdc5c1a842fd3b0bde47e986a (diff) | |
download | public-inbox-aae578aad0fd1c7b788a461fa29cb70f0a29fb02.tar.gz |
A work-in-progress, but it appears the v2 UI pieces do will not require a lot of work to do.
Diffstat (limited to 't')
-rw-r--r-- | t/init.t | 15 | ||||
-rw-r--r-- | t/nntpd.t | 36 |
2 files changed, 45 insertions, 6 deletions
@@ -25,4 +25,19 @@ use constant pi_init => 'blib/script/public-inbox-init'; is((stat($cfgfile))[2] & 07777, 0666, "permissions preserved"); } +SKIP: { + foreach my $mod (qw(DBD::SQLite Search::Xapian::WritableDatabase)) { + eval "require $mod"; + skip "$mod missing for v2", 2 if $@; + } + local $ENV{PI_DIR} = "$tmpdir/.public-inbox/"; + my $cfgfile = "$ENV{PI_DIR}/config"; + my @cmd = (pi_init, '-V2', 'v2list', "$tmpdir/v2list", + qw(http://example.com/v2list v2list@example.com)); + is(system(@cmd), 0, 'public-inbox-init -V2 OK'); + ok(-d "$tmpdir/v2list", 'v2list directory exists'); + ok(-f "$tmpdir/v2list/msgmap.sqlite3", 'msgmap exists'); + ok(-d "$tmpdir/v2list/all.git", 'catch-all.git directory exists'); +} + done_testing(); @@ -21,14 +21,18 @@ my $tmpdir = tempdir('pi-nntpd-XXXXXX', TMPDIR => 1, CLEANUP => 1); my $home = "$tmpdir/pi-home"; my $err = "$tmpdir/stderr.log"; my $out = "$tmpdir/stdout.log"; -my $maindir = "$tmpdir/main.git"; +my $mainrepo = "$tmpdir/main.git"; my $group = 'test-nntpd'; my $addr = $group . '@example.com'; my $nntpd = 'blib/script/public-inbox-nntpd'; my $init = 'blib/script/public-inbox-init'; use_ok 'PublicInbox::Import'; +use_ok 'PublicInbox::Inbox'; use_ok 'PublicInbox::Git'; +use_ok 'PublicInbox::V2Writable'; +# XXX FIXME: make it easier to test both versions +my $version = int($ENV{PI_VERSION} || 1); my %opts = ( LocalAddr => '127.0.0.1', ReuseAddr => 1, @@ -40,14 +44,34 @@ my $sock = IO::Socket::INET->new(%opts); my $pid; my $len; END { kill 'TERM', $pid if defined $pid }; + +my $ibx = { + mainrepo => $mainrepo, + name => $group, + version => $version, + -primary_address => $addr, +}; +$ibx = PublicInbox::Inbox->new($ibx); { local $ENV{HOME} = $home; - system($init, $group, $maindir, 'http://example.com/', $addr); + my @cmd = ($init, $group, $mainrepo, 'http://example.com/', $addr); + push @cmd, "-V$version"; + is(system(@cmd), 0, 'init OK'); is(system(qw(git config), "--file=$home/.public-inbox/config", "publicinbox.$group.newsgroup", $group), 0, 'enabled newsgroup'); my $len; + my $im; + if ($version == 2) { + $im = PublicInbox::V2Writable->new($ibx); + } elsif ($version == 1) { + my $git = PublicInbox::Git->new($mainrepo); + $im = PublicInbox::Import->new($git, 'test', $addr); + } else { + die "unsupported version: $version"; + } + # ensure successful message delivery { my $mime = Email::MIME->new(<<EOF); @@ -66,12 +90,12 @@ EOF $list_id =~ s/@/./; $mime->header_set('List-Id', "<$list_id>"); $len = length($mime->as_string); - my $git = PublicInbox::Git->new($maindir); - my $im = PublicInbox::Import->new($git, 'test', $addr); $im->add($mime); $im->done; - my $s = PublicInbox::SearchIdx->new($maindir, 1); - $s->index_sync; + if ($version == 1) { + my $s = PublicInbox::SearchIdx->new($mainrepo, 1); + $s->index_sync; + } } ok($sock, 'sock created'); |