source: bookmarks/trunk/t/01-bookmark.t @ 106

Last change on this file since 106 was 92, checked in by peter, 9 years ago

issue #10: added basic test of the web app and the Bookmark class

To make the application testable, BookmarksApp now does not require a
config_file to be set, and can just be configured via a config hash in the
constructor. In addition, authentication and reverse proxy rewriting are now
conditionally enabled based on whether there is an auth and proxy_ip key in
the config, respecitvely.

Added Plack 1.0036 to the cpanfile dependencies, since that is the version that
contains Plack::Test.

Also fixed the Bookmarks::create_tables() method to load the
bookmarks.sql file from the correct location.

File size: 1012 bytes
Line 
1#!/usr/bin/perl -w
2use strict;
3
4use Test::More;
5
6use Bookmark;
7
8subtest 'Basic bookmark' => sub {
9    my $time_1 = time - 30;
10    my $time_2 = time;
11    my $bookmark = Bookmark->new({
12        id => 1,
13        uri => 'http://metacpan.org',
14        title => 'My Bookmark',
15        ctime => $time_1,
16        mtime => $time_2,
17        tags => [qw{test}],
18    });
19
20    is($bookmark->id, 1, 'id set okay');
21    is($bookmark->uri, 'http://metacpan.org', 'uri set okay');
22    is($bookmark->title, 'My Bookmark', 'title set okay');
23    is($bookmark->ctime, $time_1, 'ctime set okay');
24    is($bookmark->mtime, $time_2, 'mtime set okay');
25    is_deeply($bookmark->tags, [qw{test}], 'tags set okay');
26};
27
28subtest 'Implicit mtime' => sub {
29    my $time = time;
30    my $bookmark = Bookmark->new({
31        id => 1,
32        uri => 'http://metacpan.org',
33        title => 'My Bookmark',
34        ctime => $time,
35        tags => [qw{test}],
36    });
37
38    is($bookmark->mtime, $time, 'implicit mtime set okay');
39};
40
41done_testing();
Note: See TracBrowser for help on using the repository browser.