]> iEval git - webservice-vichan.git/blame_incremental - t/WebService-Vichan.t
Bump version and update Changes
[webservice-vichan.git] / t / WebService-Vichan.t
... / ...
CommitLineData
1#!/usr/bin/perl
2use strict;
3use warnings;
4
5use Test::RequiresInternet ('a.4cdn.org' => 443, '8ch.net' => 443);
6use Test::More tests => 17;
7
8BEGIN { use_ok('WebService::Vichan', ':all') };
9
10my @URLS = (API_4CHAN, API_8CHAN);
11
12for my $url (@URLS) {
13 note "Now testing $url";
14 my $chan = WebService::Vichan->new($url);
15
16 my @boards = $chan->boards;
17 ok @boards > 0, 'has boards';
18
19 my $board = $boards[0];
20 my $boardcode = $board->board;
21
22 my @threads = $chan->threads($board);
23 my @threads_flat = $chan->threads_flat($board);
24 ok @threads > 0, "board $boardcode has threads";
25
26 SKIP: {
27 skip 'race condition', 1 unless $ENV{RELEASE_TESTING};
28 my $thread3a = $threads[0]->threads->[2];
29 my $thread3b = $threads_flat[2];
30 is $thread3a->no, $thread3b->no, 'same 3rd thread in threads and threads_flat';
31 }
32
33 my @catalog = $chan->catalog($board);
34 my @catalog_flat = $chan->catalog_flat($board);
35 ok @catalog > 0, "catalog of board $boardcode is not empty";
36
37 SKIP: {
38 skip 'race condition', 1 unless $ENV{RELEASE_TESTING};
39 my $catalog3a = $catalog[0]->threads->[2];
40 my $catalog3b = $catalog_flat[2];
41 is $catalog3a->no, $catalog3b->no, 'same 3rd thread in catalog and catalog_flat';
42 }
43
44 my $catalog3 = $catalog_flat[2];
45 my $catalog3no = $catalog3->no;
46 my $has_content = defined $catalog3->com || defined $catalog3->filename;
47 ok $has_content, "third entry in catalog of board $boardcode has content";
48
49 my @posts = $chan->thread($board, $catalog3);
50 ok @posts > 0, "thread $catalog3no has posts";
51
52 is $catalog3->id, $posts[0]->id, 'catalog entry has same ID as first post';
53}
This page took 0.023901 seconds and 5 git commands to generate.