changeset 46:239a346b4913

Tests: add proxy_store basic tests.
author Maxim Dounin <mdounin@mdounin.ru>
date Mon, 10 Nov 2008 19:04:34 +0300
parents d68b85def521
children bb6d65d833cd
files lib/Test/Nginx.pm proxy-store.t
diffstat 2 files changed, 69 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/lib/Test/Nginx.pm
+++ b/lib/Test/Nginx.pm
@@ -167,6 +167,11 @@ sub run_daemon($;@) {
 	return $self;
 }
 
+sub testdir() {
+	my ($self) = @_;
+	return $self->{_testdir};
+}
+
 ###############################################################################
 
 sub log_out {
new file mode 100644
--- /dev/null
+++ b/proxy-store.t
@@ -0,0 +1,64 @@
+#!/usr/bin/perl
+
+# (C) Maxim Dounin
+
+# Tests for proxy_store functionality.
+
+###############################################################################
+
+use warnings;
+use strict;
+
+use Test::More tests => 2;
+
+BEGIN { use FindBin; chdir($FindBin::Bin); }
+
+use lib 'lib';
+use Test::Nginx;
+
+###############################################################################
+
+select STDERR; $| = 1;
+select STDOUT; $| = 1;
+
+my $t = Test::Nginx->new();
+
+$t->write_file_expand('nginx.conf', <<'EOF');
+
+master_process off;
+daemon         off;
+
+events {
+    worker_connections  1024;
+}
+
+http {
+    access_log    off;
+    root          %%TESTDIR%%;
+
+    client_body_temp_path  %%TESTDIR%%/client_body_temp;
+    fastcgi_temp_path      %%TESTDIR%%/fastcgi_temp;
+    proxy_temp_path        %%TESTDIR%%/proxy_temp;
+
+    server {
+        listen       127.0.0.1:8080;
+        server_name  localhost;
+
+        location /store {
+            proxy_pass http://127.0.0.1:8080/index.html;
+            proxy_store on;
+        }
+    }
+}
+
+EOF
+
+$t->write_file('index.html', 'SEE-THIS');
+$t->run();
+
+###############################################################################
+
+like(http_get('/store'), qr/SEE-THIS/, 'proxy request');
+ok(-e $t->testdir() . '/store', 'result stored');
+
+###############################################################################