File: 22_twitter_insanity.t

package info (click to toggle)
libnet-twitter-perl 4.01043-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster
  • size: 844 kB
  • sloc: perl: 6,703; makefile: 13
file content (25 lines) | stat: -rw-r--r-- 769 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!perl
use warnings;
use strict;
use Test::More;
use lib qw(t/lib);

eval 'use TestUA';
plan skip_all => 'LWP::UserAgent 5.819 required for tests' if $@;

plan tests => 1;

use Net::Twitter;

# For end_session, on success, twitter returns status code 200 and an ERROR
# payload!!!

my $nt = Net::Twitter->new(ssl => 0, legacy => 0, username => 'me', password => 'secret');
my $t  = TestUA->new(1, $nt->ua);
$t->response->content('{"error":"Logged out.","request":"/account/end_session.json"}');

# This test will always succeed since we're spoofing the response
# from Twitter. It's simply meant to demonstrate Twitter's behavior.
# Should we thorw an error, or should we return the HASH?
my $r = eval { $nt->end_session };
like $@, qr/Logged out/, 'error on success';