Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Finished tests

* Will add more in the future if needed
* Prep for release to CPAN
  • Loading branch information...
commit ca1903e957ee3b5ea879f81d3d8dbe89a3e40a89 1 parent 21b0539
Mark Allen authored
8 Build.PL
@@ -9,16 +9,16 @@ my $builder = Module::Build->new(
9 9 dist_version_from => 'lib/Net/API/Gett.pm',
10 10 build_requires => {
11 11 'Test::More' => 0,
  12 + },
  13 + requires => {
  14 + 'perl' => 5.010,
  15 + 'LWP::Protocol::https' => 0,
12 16 'Moo' => 0,
13 17 'Sub::Quote' => 0,
14 18 'LWP' => 0,
15 19 'JSON' => 0,
16 20 'File::Slurp' => 0,
17 21 },
18   - requires => {
19   - 'perl' => 5.010,
20   - 'LWP::Protocol::https' => 0,
21   - },
22 22 add_to_cleanup => [ 'Net-API-Gett-*' ],
23 23 create_makefile_pl => 'traditional',
24 24 );
3  MANIFEST
@@ -5,9 +5,10 @@ lib/Net/API/Gett/User.pm
5 5 lib/Net/API/Gett/Share.pm
6 6 lib/Net/API/Gett/File.pm
7 7 MANIFEST This list of files
  8 +MANIFEST.SKIP
8 9 README
  10 +ignore.txt
9 11 t/00-load.t
10 12 t/01-basic.t
11   -t/02-author.t
12 13 t/manifest.t
13 14 t/pod.t
1  MANIFEST.SKIP
... ... @@ -0,0 +1 @@
  1 +.git
1  ignore.txt
@@ -10,3 +10,4 @@ pm_to_blib*
10 10 cover_db
11 11 pod2htm*.tmp
12 12 Net-API-Gett-*
  13 +.git*
48 t/01-basic.t
... ... @@ -0,0 +1,48 @@
  1 +#!/usr/bin/perl
  2 +
  3 +use strict;
  4 +use Test::More;
  5 +
  6 +if (!eval { require Socket; Socket::inet_aton('open.ge.tt') }) {
  7 + plan skip_all => "Cannot connect to the API server";
  8 +}
  9 +else {
  10 + plan tests => 12;
  11 +}
  12 +
  13 +use Net::API::Gett;
  14 +
  15 +# doesn't require auth
  16 +# get_share()
  17 +# get_file()
  18 +# get_file_content()
  19 +
  20 +my $gett = Net::API::Gett->new(
  21 + api_key => "fake",
  22 + email => 'me@example.com',
  23 + password => 'fake',
  24 +);
  25 +
  26 +isa_ok($gett, 'Net::API::Gett', "Gett object constructed");
  27 +
  28 +my $share = $gett->get_share("928PBdA");
  29 +
  30 +isa_ok($share, 'Net::API::Gett::Share', "share object constructed");
  31 +
  32 +is($share->sharename, "928PBdA", "got share name");
  33 +is($share->created, "1322847473", "got share created");
  34 +like($share->title, qr/Test/, "got share title");
  35 +is(scalar $share->files, 2, "got 2 files");
  36 +
  37 +my $file = $gett->get_file("928PBdA", 0); #hello.c
  38 +
  39 +isa_ok($file, 'Net::API::Gett::File', "file object constructed");
  40 +
  41 +is($file->created, 1322847473, "got file created");
  42 +is($file->fileid, 0, "got fileid");
  43 +is($file->filename, "hello.c", "got filename");
  44 +
  45 +my $contents = $gett->get_file_contents("928PBdA", 0);
  46 +
  47 +like($contents, qr/Hello world/, "Got hello.c content");
  48 +is(length($contents), $file->size, "file content size matches file object");
56 t/boilerplate.t
... ... @@ -1,56 +0,0 @@
1   -#!perl -T
2   -
3   -use 5.006;
4   -use strict;
5   -use warnings;
6   -use Test::More tests => 3;
7   -
8   -sub not_in_file_ok {
9   - my ($filename, %regex) = @_;
10   - open( my $fh, '<', $filename )
11   - or die "couldn't open $filename for reading: $!";
12   -
13   - my %violated;
14   -
15   - while (my $line = <$fh>) {
16   - while (my ($desc, $regex) = each %regex) {
17   - if ($line =~ $regex) {
18   - push @{$violated{$desc}||=[]}, $.;
19   - }
20   - }
21   - }
22   -
23   - if (%violated) {
24   - fail("$filename contains boilerplate text");
25   - diag "$_ appears on lines @{$violated{$_}}" for keys %violated;
26   - } else {
27   - pass("$filename contains no boilerplate text");
28   - }
29   -}
30   -
31   -sub module_boilerplate_ok {
32   - my ($module) = @_;
33   - not_in_file_ok($module =>
34   - 'the great new $MODULENAME' => qr/ - The great new /,
35   - 'boilerplate description' => qr/Quick summary of what the module/,
36   - 'stub function definition' => qr/function[12]/,
37   - );
38   -}
39   -
40   -TODO: {
41   - local $TODO = "Need to replace the boilerplate text";
42   -
43   - not_in_file_ok(README =>
44   - "The README is used..." => qr/The README is used/,
45   - "'version information here'" => qr/to provide version information/,
46   - );
47   -
48   - not_in_file_ok(Changes =>
49   - "placeholder date/time" => qr(Date/time)
50   - );
51   -
52   - module_boilerplate_ok('lib/Net/API/Gett.pm');
53   -
54   -
55   -}
56   -

0 comments on commit ca1903e

Please sign in to comment.
Something went wrong with that request. Please try again.