3
3
use lib ' lib' ;
4
4
use Test::Nginx::Socket;
5
5
6
- plan tests => repeat_each() * 92 ;
6
+ plan tests => repeat_each() * 97 ;
7
7
8
8
$ENV {TEST_NGINX_MEMCACHED_PORT } ||= 11211;
9
9
@@ -312,6 +312,7 @@ GET /flush
312
312
GET /foo HTTP/1.0
313
313
--- response_headers
314
314
Content-Type: text/html
315
+ Location: /bah
315
316
--- response_body_like: 302 Found
316
317
--- error_code: 302
317
318
@@ -339,7 +340,37 @@ Location: /bah\r
339
340
340
341
341
342
342
- === TEST 16: flush all
343
+ === TEST 16: cache hit
344
+ --- config
345
+ location /foo {
346
+ default_type text/css;
347
+ srcache_fetch GET /memc $uri;
348
+ srcache_store PUT /memc $uri;
349
+ srcache_store_statuses 303 304;
350
+
351
+ content_by_lua '
352
+ ngx.say("hi")
353
+ ';
354
+ }
355
+
356
+ location /memc {
357
+ internal;
358
+
359
+ set $memc_key $query_string;
360
+ set $memc_exptime 300;
361
+ memc_pass 127.0.0.1:$TEST_NGINX_MEMCACHED_PORT;
362
+ }
363
+ --- request
364
+ GET /foo HTTP/1.0
365
+ --- response_headers
366
+ Content-Type: text/html
367
+ Location: /bah
368
+ --- response_body_like: 302 Found
369
+ --- error_code: 302
370
+
371
+
372
+
373
+ === TEST 17: flush all
343
374
--- config
344
375
location /flush {
345
376
set $memc_cmd 'flush_all';
@@ -355,7 +386,7 @@ GET /flush
355
386
356
387
357
388
358
- === TEST 17 : basic fetch (201 not cached by default)
389
+ === TEST 18 : basic fetch (201 not cached by default)
359
390
--- config
360
391
location /foo {
361
392
default_type text/css;
@@ -385,7 +416,7 @@ Dog created
385
416
386
417
387
418
388
- === TEST 18 : inspect the cached item
419
+ === TEST 19 : inspect the cached item
389
420
--- config
390
421
location /memc {
391
422
set $memc_key "/foo";
@@ -403,7 +434,7 @@ Content-Type: text/html
403
434
404
435
405
436
406
- === TEST 19 : flush all
437
+ === TEST 20 : flush all
407
438
--- config
408
439
location /flush {
409
440
set $memc_cmd 'flush_all';
@@ -419,7 +450,7 @@ GET /flush
419
450
420
451
421
452
422
- === TEST 20 : basic fetch (explicitly do not cache 302)
453
+ === TEST 21 : basic fetch (explicitly do not cache 302)
423
454
--- config
424
455
location /foo {
425
456
default_type text/css;
@@ -448,7 +479,7 @@ Content-Type: text/html
448
479
449
480
450
481
451
- === TEST 21 : inspect the cached item
482
+ === TEST 22 : inspect the cached item
452
483
--- config
453
484
location /memc {
454
485
set $memc_key "/foo";
@@ -466,7 +497,7 @@ Content-Type: text/html
466
497
467
498
468
499
469
- === TEST 22 : flush all
500
+ === TEST 23 : flush all
470
501
--- config
471
502
location /flush {
472
503
set $memc_cmd 'flush_all';
@@ -482,7 +513,7 @@ GET /flush
482
513
483
514
484
515
485
- === TEST 23 : basic fetch (explicitly do not cache 302, and store_statuses are all bigger than 302)
516
+ === TEST 24 : basic fetch (explicitly do not cache 302, and store_statuses are all bigger than 302)
486
517
github pull #19
487
518
--- config
488
519
location /foo {
@@ -512,7 +543,7 @@ Content-Type: text/html
512
543
513
544
514
545
515
- === TEST 24 : inspect the cached item
546
+ === TEST 25 : inspect the cached item
516
547
--- config
517
548
location /memc {
518
549
set $memc_key "/foo";
0 commit comments