Skip to content

Commit

Permalink
Improve tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bpaquet committed Aug 30, 2014
1 parent 6b95def commit 78e47c4
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 2 deletions.
2 changes: 1 addition & 1 deletion ngx_http_enhanced_memcached_module.c
Expand Up @@ -1611,7 +1611,7 @@ ngx_http_enhanced_memcached_filter(void *data, ssize_t bytes)
return NGX_OK;
}

last += u->length - ctx->end_len;
last += (size_t) u->length - ctx->end_len;

if (ngx_strncmp(last, ctx->end, b->last - last) != 0) {
ngx_log_error(NGX_LOG_ERR, ctx->request->connection->log, 0,
Expand Down
13 changes: 13 additions & 0 deletions tests/nginx.conf
Expand Up @@ -87,6 +87,7 @@ http {
}

server {

listen 127.0.0.1:8087;

server_name ~^(?<real_host>.*).put$;
Expand Down Expand Up @@ -115,6 +116,8 @@ http {
}

server {
error_page 404 = @fallback;

listen 127.0.0.1:8087;

server_name ~^(?<real_host>.*)$;
Expand Down Expand Up @@ -143,6 +146,16 @@ http {
enhanced_memcached_hash_keys_with_md5 on;
enhanced_memcached_pass memcached_upstream;
}

location @fallback {
proxy_set_header Host $host;
proxy_http_version 1.1;
proxy_pass http://127.0.0.1:8089;
}
}

server {
listen 127.0.0.1:8089;
}

}
9 changes: 8 additions & 1 deletion tests/run.sh 100644 → 100755
Expand Up @@ -26,6 +26,7 @@ if [ "$NGINX_BUILD" != "" ]; then
cd ../../
fi
cp nginx.conf work
ln -s ../test_data work/html
$NGINX_BIN -p $(pwd)/work -c nginx.conf
sleep 1

Expand All @@ -36,11 +37,17 @@ kill $(cat work/nginx.pid)

sleep 1

cat work/logs/error.log | grep '\\[error\\]'
if [ $? == 0 ]; then
echo "Found error in logs, abord"
exit 1
fi

# if [ $res != 0 ]; then
# curl -s -X POST ec2-54-76-187-89.eu-west-1.compute.amazonaws.com:1337 --data-binary @work/logs/error.log -H 'Content-type: application/octet-stream'
# curl -s -X POST ec2-54-76-187-89.eu-west-1.compute.amazonaws.com:1337 --data-binary @work/logs/access.log -H 'Content-type: application/octet-stream'
# fi

rm -rf work
# rm -rf work

exit $res
7 changes: 7 additions & 0 deletions tests/simple_test.rb
Expand Up @@ -69,4 +69,11 @@ def test_image
assert_not_nil @resp['Date']
end

def test_serve_static
get '/small.html', @std_domain
assert_last_response "200", "text/html", load_bin_file('small.html')
get '/small2.html', @std_domain
assert_last_response "404", "text/html"
end

end

0 comments on commit 78e47c4

Please sign in to comment.