summaryrefslogtreecommitdiff
path: root/t/10errbuf.t
diff options
context:
space:
mode:
Diffstat (limited to 't/10errbuf.t')
-rw-r--r--t/10errbuf.t40
1 files changed, 40 insertions, 0 deletions
diff --git a/t/10errbuf.t b/t/10errbuf.t
new file mode 100644
index 0000000..8349b1b
--- /dev/null
+++ b/t/10errbuf.t
@@ -0,0 +1,40 @@
+#!perl
+
+use strict;
+use warnings;
+use Test::More tests => 12;
+use File::Temp qw/tempfile/;
+
+BEGIN { use_ok( 'WWW::Curl::Easy' ); }
+
+my $url = $ENV{CURL_TEST_URL} || "http://www.google.com";
+
+# Init the curl session
+my $curl = WWW::Curl::Easy->new();
+ok($curl, 'Curl session initialize returns something');
+ok(ref($curl) eq 'WWW::Curl::Easy', 'Curl session looks like an object from the WWW::Curl::Easy module');
+
+ok(! $curl->setopt(CURLOPT_NOPROGRESS, 1), "Setting CURLOPT_NOPROGRESS");
+ok(! $curl->setopt(CURLOPT_FOLLOWLOCATION, 1), "Setting CURLOPT_FOLLOWLOCATION");
+ok(! $curl->setopt(CURLOPT_TIMEOUT, 30), "Setting CURLOPT_TIMEOUT");
+
+my $head = tempfile();
+ok(! $curl->setopt(CURLOPT_WRITEHEADER, $head), "Setting CURLOPT_WRITEHEADER");
+
+my $body = tempfile();
+ok(! $curl->setopt(CURLOPT_FILE, $body), "Setting CURLOPT_FILE");
+
+ok(! $curl->setopt(CURLOPT_URL, $url), "Setting CURLOPT_URL");
+
+my $new_error = tempfile();
+ok(! $curl->setopt(CURLOPT_STDERR, $new_error), "Setting CURLOPT_STDERR");
+
+# create a (hopefully) bad URL, so we get an error
+
+ok(! $curl->setopt(CURLOPT_URL, "badprotocol://127.0.0.1:2"), "Setting CURLOPT_URL succeeds, even with a bad protocol");
+
+my $retcode = $curl->perform();
+
+ok($retcode, "Non-zero return code indicates the expected failure");
+
+exit;