[Bps-public-commit] r17631 - in Net-Google-Code/trunk: .
sunnavy at bestpractical.com
sunnavy at bestpractical.com
Thu Jan 8 01:41:32 EST 2009
Author: sunnavy
Date: Thu Jan 8 01:41:24 2009
New Revision: 17631
Added:
Net-Google-Code/trunk/t/02.issue.t
Modified:
Net-Google-Code/trunk/ (props changed)
Net-Google-Code/trunk/t/10.downloads.t
Net-Google-Code/trunk/t/11.wiki.t
Log:
r18638 at sunnavys-mb: sunnavy | 2009-01-08 14:40:49 +0800
use File::Slurp from now on
Added: Net-Google-Code/trunk/t/02.issue.t
==============================================================================
--- (empty file)
+++ Net-Google-Code/trunk/t/02.issue.t Thu Jan 8 01:41:24 2009
@@ -0,0 +1,84 @@
+use strict;
+use warnings;
+
+use Test::More tests => 18;
+use Test::MockModule;
+
+# $content is a real page: http://code.google.com/p/chromium/issues/detail?id=14
+# we faked something to meet some situations, which are commented below
+
+use FindBin qw/$Bin/;
+use File::Slurp;
+
+my $content = read_file( "$Bin/sample/02.issue.html" );
+
+my $mock_connection = Test::MockModule->new('Net::Google::Code::Connection');
+$mock_connection->mock(
+ '_fetch',
+ sub { $content }
+);
+
+use_ok('Net::Google::Code::Connection');
+use_ok('Net::Google::Code::Issue');
+my $connection = Net::Google::Code::Connection->new( project => 'test' );
+my $ticket = Net::Google::Code::Issue->new( connection => $connection );
+isa_ok( $ticket, 'Net::Google::Code::Issue', '$ticket' );
+isa_ok( $ticket->connection, 'Net::Google::Code::Connection', '$ticket->connection' );
+$ticket->load(14);
+
+my $description = <<"EOF";
+What steps will reproduce the problem?
+
+Attempt to install chrome behind a firewall blocking HTTP/HTTPS traffic.
+
+What is the expected result?
+
+Options for proxy settings to allow the installer to retrieve the necessary
+data via a proxy.
+
+What happens instead?
+
+Installer simply fails, notifying the user to adjust their firewall settings.
+EOF
+
+my %info = (
+ id => 14,
+ summary => 'Proxy settings for installer',
+ description => $description,
+ cc => 'thatan... at google.com',
+ owner => 'all-bugs-test at chromium.org',
+ reporter => 'seanamonroe',
+ status => 'Available',
+ closed => undef,
+);
+
+my %labels = (
+ Type => 'Bug',
+ Pri => 2,
+ OS => 'All',
+ Area => 'Installer',
+ intext => undef,
+ Mstone => 'X',
+ Foo => 'Bar-Baz', # this is one we fake, for more than 1 hyphen
+);
+
+for my $item ( qw/id summary description owner cc reporter status closed/ ) {
+ if ( defined $info{$item} ) {
+ is ( $ticket->$item, $info{$item}, "$item is extracted" );
+ }
+ else {
+ ok( !defined $ticket->$item, "$item is not defined" );
+ }
+}
+
+is_deeply( $ticket->labels, \%labels, 'labels is extracted' );
+
+is( scalar @{$ticket->comments}, 50, 'comments are extracted' );
+is( $ticket->comments->[0]->sequence, 1, 'sequence of 1st comments is 1' );
+# seems comments 2 and 3 are deleted
+is( $ticket->comments->[1]->sequence, 4, 'sequence of 2nd comments is 4' );
+
+# attachments part are faked from
+# http://code.google.com/p/chromium/issues/detail?id=683
+is( scalar @{ $ticket->attachments }, 3, 'attachments are extracted' );
+is( $ticket->attachments->[0]->size, '11.7 KB', 'size of the 1st attachment' );
Modified: Net-Google-Code/trunk/t/10.downloads.t
==============================================================================
--- Net-Google-Code/trunk/t/10.downloads.t (original)
+++ Net-Google-Code/trunk/t/10.downloads.t Thu Jan 8 01:41:24 2009
@@ -6,18 +6,11 @@
use Test::More tests => 15;
use Test::MockModule;
use FindBin qw/$Bin/;
+use File::Slurp;
my $feed_file = "$Bin/sample/10.download.xml";
my $down_file = "$Bin/sample/10.download.html";
-sub read_file {
- open(my $fh, '<', shift) or die $!;
- local $/;
- my $t = <$fh>;
- close($fh);
- return $t;
-}
-
my $feed_content = read_file($feed_file);
my $download_content = read_file($down_file);
@@ -56,4 +49,4 @@
is $entry->{file_size}, '37.4 KB';
is $entry->{file_SHA1}, '5073de2276f916cf5d74d7abfd78a463e15674a1';
-1;
\ No newline at end of file
+1;
Modified: Net-Google-Code/trunk/t/11.wiki.t
==============================================================================
--- Net-Google-Code/trunk/t/11.wiki.t (original)
+++ Net-Google-Code/trunk/t/11.wiki.t Thu Jan 8 01:41:24 2009
@@ -6,18 +6,10 @@
use Test::More tests => 9;
use Test::MockModule;
use FindBin qw/$Bin/;
+use File::Slurp;
my $svn_file = "$Bin/sample/11.wiki.html";
my $wiki_file = "$Bin/sample/11.TODO.wiki";
-
-sub read_file {
- open(my $fh, '<', shift) or die $!;
- local $/;
- my $t = <$fh>;
- close($fh);
- return $t;
-}
-
my $svn_content = read_file($svn_file);
my $wiki_content = read_file($wiki_file);
@@ -52,4 +44,5 @@
isa_ok( $entry, 'Net::Google::Code::WikiEntry' );
is $entry->source, 'Please check [http://code.google.com/p/foorum/issues/list] for more issues.';
-1;
\ No newline at end of file
+1;
+
More information about the Bps-public-commit
mailing list