1 |
#!/usr/bin/env perl |
2 |
use warnings; |
3 |
use strict; |
4 |
|
5 |
=head1 DESCRIPTION |
6 |
|
7 |
A basic test harness for the Feed model. |
8 |
|
9 |
=cut |
10 |
|
11 |
use Jifty::Test tests => 11; |
12 |
|
13 |
use blib; |
14 |
|
15 |
# Make sure we can load the model |
16 |
use_ok('Grep::Model::Feed'); |
17 |
|
18 |
# Grab a system user |
19 |
my $system_user = Grep::CurrentUser->superuser; |
20 |
ok($system_user, "Found a system user"); |
21 |
|
22 |
# Try testing a create |
23 |
my $o = Grep::Model::Feed->new(current_user => $system_user); |
24 |
my ($id) = $o->create( |
25 |
uri => 'http://saturn.ffzg.hr/noauth/feed/workspace/rot13?search_term=%s', |
26 |
title => 'rot13.org wiki', |
27 |
|
28 |
); |
29 |
ok($id, "Feed create returned success"); |
30 |
ok($o->id, "New Feed has valid id set"); |
31 |
is($o->id, $id, "Create returned the right id"); |
32 |
|
33 |
# And another |
34 |
$o->create( |
35 |
uri => 'https://blog.rot13.org/', |
36 |
title => 'my blog', |
37 |
); |
38 |
ok($o->id, "Feed create returned another value"); |
39 |
isnt($o->id, $id, "And it is different from the previous one"); |
40 |
|
41 |
# Searches in general |
42 |
my $collection = Grep::Model::FeedCollection->new(current_user => $system_user); |
43 |
$collection->unlimit; |
44 |
is($collection->count, 2, "Finds two records"); |
45 |
|
46 |
# Searches in specific |
47 |
$collection->limit(column => 'id', value => $o->id); |
48 |
is($collection->count, 1, "Finds one record with specific id"); |
49 |
|
50 |
# Delete one of them |
51 |
$o->delete; |
52 |
$collection->redo_search; |
53 |
is($collection->count, 0, "Deleted row is gone"); |
54 |
|
55 |
# And the other one is still there |
56 |
$collection->unlimit; |
57 |
is($collection->count, 1, "Still one left"); |
58 |
|