From 528230a0411897a14cbb79d0dae02ea89827bf1e Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sat, 28 May 2016 01:57:14 +0000 Subject: remove redundant NewsGroup class Most of its functionality is in the PublicInbox::Inbox class. While we're at it, we no longer auto-create newsgroup names based on the inbox name, since newsgroup names probably deserve some thought when it comes to hierarchy. --- t/config.t | 2 ++ t/nntp.t | 15 ++++++++++----- t/nntpd.t | 4 +++- 3 files changed, 15 insertions(+), 6 deletions(-) (limited to 't') diff --git a/t/config.t b/t/config.t index 78971a2f..dc448cdf 100644 --- a/t/config.t +++ b/t/config.t @@ -26,6 +26,7 @@ my $tmpdir = tempdir('pi-config-XXXXXX', TMPDIR => 1, CLEANUP => 1); is_deeply($cfg->lookup('meta@public-inbox.org'), { 'mainrepo' => '/home/pi/meta-main.git', 'address' => 'meta@public-inbox.org', + 'domain' => 'public-inbox.org', 'url' => 'http://example.com/meta', -primary_address => 'meta@public-inbox.org', 'name' => 'meta', @@ -41,6 +42,7 @@ my $tmpdir = tempdir('pi-config-XXXXXX', TMPDIR => 1, CLEANUP => 1); 'test@public-inbox.org'], -primary_address => 'try@public-inbox.org', 'mainrepo' => '/home/pi/test-main.git', + 'domain' => 'public-inbox.org', 'name' => 'test', 'url' => 'http://example.com/test', }, "lookup matches expected output for test"); diff --git a/t/nntp.t b/t/nntp.t index 5513c7bc..de07abb0 100644 --- a/t/nntp.t +++ b/t/nntp.t @@ -11,7 +11,7 @@ foreach my $mod (qw(DBD::SQLite Search::Xapian Danga::Socket)) { } use_ok 'PublicInbox::NNTP'; -use_ok 'PublicInbox::NewsGroup'; +use_ok 'PublicInbox::Inbox'; { sub quote_str { @@ -99,9 +99,14 @@ use_ok 'PublicInbox::NewsGroup'; { # test setting NNTP headers in HEAD and ARTICLE requests require Email::MIME; my $u = 'https://example.com/a/'; - my $ng = PublicInbox::NewsGroup->new('test', 'test.git', - 'a@example.com', '//example.com/a'); - is($ng->{url}, $u, 'URL expanded'); + my $ng = PublicInbox::Inbox->new({ name => 'test', + mainrepo => 'test.git', + address => 'a@example.com', + -primary_address => 'a@example.com', + newsgroup => 'test', + domain => 'example.com', + url => '//example.com/a'}); + is($ng->base_url, $u, 'URL expanded'); my $mid = 'a@b'; my $mime = Email::MIME->new("Message-ID: <$mid>\r\n\r\n"); PublicInbox::NNTP::set_nntp_headers($mime->header_obj, $ng, 1, $mid); @@ -118,7 +123,7 @@ use_ok 'PublicInbox::NewsGroup'; is_deeply([ $mime->header('Xref') ], [ 'example.com test:1' ], 'Xref: set'); - $ng->{url} = 'http://mirror.example.com/m/'; + $ng->{-base_url} = 'http://mirror.example.com/m/'; PublicInbox::NNTP::set_nntp_headers($mime->header_obj, $ng, 2, $mid); is_deeply([ $mime->header('Message-ID') ], [ "<$mid>" ], 'Message-ID unchanged'); diff --git a/t/nntpd.t b/t/nntpd.t index 837b9d46..c5bc0b54 100644 --- a/t/nntpd.t +++ b/t/nntpd.t @@ -24,7 +24,6 @@ my $out = "$tmpdir/stdout.log"; my $maindir = "$tmpdir/main.git"; my $group = 'test-nntpd'; my $addr = $group . '@example.com'; -my $cfgpfx = "publicinbox.$group"; my $nntpd = 'blib/script/public-inbox-nntpd'; my $init = 'blib/script/public-inbox-init'; use_ok 'PublicInbox::Import'; @@ -44,6 +43,9 @@ END { kill 'TERM', $pid if defined $pid }; { local $ENV{HOME} = $home; system($init, $group, $maindir, 'http://example.com/', $addr); + is(system(qw(git config), "--file=$home/.public-inbox/config", + "publicinbox.$group.newsgroup", $group), + 0, 'enabled newsgroup'); my $len; # ensure successful message delivery -- cgit v1.2.3-24-ge0c7