Skip to content

Commit

Permalink
Merge pull request #54 from schwern/feature/author_tests_for_all
Browse files Browse the repository at this point in the history
Author tests for all
  • Loading branch information
fayland committed Oct 31, 2014
2 parents 2bdcee8 + d382321 commit bec6ed0
Show file tree
Hide file tree
Showing 10 changed files with 39 additions and 53 deletions.
3 changes: 0 additions & 3 deletions xt/v3/01-access-token.t
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,8 @@ my $data = $gh->user->show();

ok( $data );
ok( $data->{id} );
ok( $data->{gravatar_id} );
ok( $data->{email} );
ok( $data->{login} );
ok( $data->{name} );

done_testing;

1;
5 changes: 0 additions & 5 deletions xt/v3/02-user-pass.t
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,10 @@ diag( 'Using user = ' . $ENV{GITHUB_USER} );
ok( $gh );
my $data = $gh->user->show();

# use Data::Dumper;
# diag(Dumper(\$data));

ok( $data );
ok( $data->{id} );
ok( $data->{email} );
ok( $data->{login} );
ok( $data->{name} );

done_testing;

1;
2 changes: 0 additions & 2 deletions xt/v3/100-users.t
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,3 @@ if ($is_following) {
=cut

done_testing;

1;
16 changes: 5 additions & 11 deletions xt/v3/200-repos.t
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,18 @@ use warnings;
use Test::More;
use Net::GitHub::V3;

plan skip_all => 'Please export environment variable GITHUB_USER/GITHUB_PASS'
unless $ENV{GITHUB_USER} and $ENV{GITHUB_PASS};

my $gh = Net::GitHub::V3->new( login => $ENV{GITHUB_USER}, pass => $ENV{GITHUB_PASS});
my $gh = Net::GitHub::V3->new;
my $repos = $gh->repos;

diag( 'Using user = ' . $ENV{GITHUB_USER} );

ok( $gh );
ok( $repos );

my @p = $repos->list;
ok(@p > 3, 'more than 3 repos');
my @p = $repos->list_user('fayland');
cmp_ok(@p, ">", 3, 'more than 3 repos');

my $rp = $repos->get('fayland', 'perl-net-github');
diag(Dumper(\$rp)); use Data::Dumper;
is $rp->{name}, "perl-net-github";
is $rp->{owner}{login}, "fayland" or diag explain $rp;


=pod
Expand Down Expand Up @@ -54,5 +50,3 @@ is($st, 1);
=cut

done_testing;

1;
12 changes: 7 additions & 5 deletions xt/v3/300-pull.t
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use strict;
use warnings;
use Test::More;
use Net::GitHub::V3;
use Data::Dumper;

plan skip_all => 'Please export environment variable GITHUB_USER/GITHUB_PASS'
unless $ENV{GITHUB_USER} and $ENV{GITHUB_PASS};
Expand All @@ -17,9 +16,12 @@ ok( $pull );

$pull->set_default_user_repo('fayland', 'perl-net-github');

my %data = $pull->pulls({ state => 'closed' });
diag Dumper(\%data);
my @closed_pull_requests = $pull->pulls({ state => 'closed' });
for my $request (@closed_pull_requests) {
is $request->{state}, "closed";
ok $request->{closed_at};
is $request->{base}{repo}{name}, "perl-net-github";
is $request->{base}{repo}{owner}{login}, "fayland";
}

done_testing;

1;
2 changes: 0 additions & 2 deletions xt/v3/500-org.t
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,3 @@ $is_member = $org->is_member('perlchina', 'nothingmuch');
is($is_member, 0);

done_testing;

1;
11 changes: 6 additions & 5 deletions xt/v3/600-git_data.t
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,13 @@ ok( $gh );
ok( $git_data );

$git_data->set_default_user_repo('fayland', 'perl-net-github');
my $blob = $git_data->blob('5a1faac3ad54da26be60970ddbbdfbf6b08fdc57');
ok($blob);

# The Github blobs API doesn't appear to be working.
#my $blob = $git_data->blob('5a1faac3ad54da26be60970ddbbdfbf6b08fdc57');
#ok($blob);

my $commit = $git_data->commit('5a1faac3ad54da26be60970ddbbdfbf6b08fdc57');
ok($commit);
is $commit->{sha}, '5a1faac3ad54da26be60970ddbbdfbf6b08fdc57';
is $commit->{message}, "init git data";

done_testing();

1;
10 changes: 4 additions & 6 deletions xt/v3/700-gists.t
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,9 @@ my $g = $gist->create( {
}
}
} );
ok($g);

use Data::Dumper;
diag(Dumper(\$g));
ok $g->{id};
ok $g->{public};
is $g->{description}, "the description for this gist";
is $g->{files}{"file1.txt"}{content}, "String file contents";

done_testing;

1;
13 changes: 8 additions & 5 deletions xt/v3/800-oauth.t
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,14 @@ my $o = $oauth->create_authorization( {
scopes => ['user', 'public_repo', 'repo', 'gist'],
note => 'test purpose',
} );
ok($o);
ok $o->{id};
is_deeply $o->{scopes}, ['user', 'public_repo', 'repo', 'gist'];
is $o->{note}, "test purpose";

use Data::Dumper;
diag(Dumper(\$o));
my $auth = $oauth->authorization($o->{id});
is $auth->{id}, $o->{id};

done_testing;
$oauth->delete_authorization($o->{id});
ok !$oauth->authorization($o->{id});

1;
done_testing;
18 changes: 9 additions & 9 deletions xt/v3/900-search.t
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@ my $search = $gh->search;
ok( $gh );
ok( $search );

my %data = $search->issues({
q => 'state:open repo:fayland/perl-net-github',
my %issues = $search->issues({
q => 'state:closed repo:fayland/perl-net-github',
});
diag Dumper(\$data{items});

#%data = $search->repositories('perl-net-github');
#diag Dumper(\$data{items});
cmp_ok $issues{total_count}, ">", 10;

#%data = $search->users('fayland');
#diag Dumper(\$data{items});
my $items = $issues{items};
for my $item (@$items) {
ok $item->{id};
is $item->{state}, "closed";
ok $item->{closed_at};
}

done_testing;

1;

0 comments on commit bec6ed0

Please sign in to comment.