Bugzilla – Attachment 9349 Details for
Bug 7248
Caching for services
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 7248 Unit test for Koha/Cache.pm (which includes Koha/Cache/Memcached.pm)
Bug-7248-Unit-test-for-KohaCachepm-which-includes-.patch (text/plain), 2.51 KB, created by
Jared Camins-Esakov
on 2012-04-29 13:15:46 UTC
(
hide
)
Description:
Bug 7248 Unit test for Koha/Cache.pm (which includes Koha/Cache/Memcached.pm)
Filename:
MIME Type:
Creator:
Jared Camins-Esakov
Created:
2012-04-29 13:15:46 UTC
Size:
2.51 KB
patch
obsolete
>From ac8f9789264ca6af697e13803196288672021b23 Mon Sep 17 00:00:00 2001 >From: Chris Hall <chrish@catalyst.net.nz> >Date: Tue, 22 Nov 2011 08:55:19 +1300 >Subject: [PATCH] Bug 7248 Unit test for Koha/Cache.pm (which includes Koha/Cache/Memcached.pm) >Content-Type: text/plain; charset="UTF-8" > >Note that in order to test Koha::Cache you must export the environment variable >MEMCACHED_SERVERS. For example: >$ export MEMCACHED_SERVERS=127.0.0.1:11211 > >Signed-off-by: Jared Camins-Esakov <jcamins@cpbibliography.com> >--- > t/Cache.t | 37 +++++++++++++++++++++++++++++++++---- > 1 files changed, 33 insertions(+), 4 deletions(-) > >diff --git a/t/Cache.t b/t/Cache.t >index dca575b..286c0c9 100644 >--- a/t/Cache.t >+++ b/t/Cache.t >@@ -1,14 +1,43 @@ > #!/usr/bin/perl >-# >-# This Koha test module is a stub! >-# Add more tests here!!! >+ >+# Tests Koha::Cache and Koha::Cache::Memcached (through Koha::Cache) > > use strict; > use warnings; > >-use Test::More tests => 1; >+use Test::More tests => 9; > > BEGIN { > use_ok('Koha::Cache'); >+ use_ok('C4::Context'); > } > >+SKIP: { >+ skip "Memcached not enabled", 7 unless C4::Context->ismemcached; >+ >+ my $cache = Koha::Cache->new ( { 'cache_servers' => $ENV{'MEMCACHED_SERVERS'} } ); >+ >+ # test fetching an item that isnt in the cache >+ is( $cache->get_from_cache("not in here"), undef, "fetching item NOT in cache"); >+ >+ # test expiry time in cache >+ $cache->set_in_cache("timeout", "I AM DATA", 1); # expiry time of 1 second >+ sleep 1; >+ is( $cache->get_from_cache("timeout"), undef, "fetching expired item from cache"); >+ >+ # test fetching a valid, non expired, item from cache >+ $cache->set_in_cache("clear_me", "I AM MORE DATA", 1000); # overly large expiry time, clear below >+ $cache->set_in_cache("dont_clear_me", "I AM MORE DATA22", 1000); # overly large expiry time, clear below >+ is( $cache->get_from_cache("clear_me"), "I AM MORE DATA", "fetching valid item from cache"); >+ >+ # test clearing from cache >+ $cache->clear_from_cache("clear_me"); >+ is( $cache->get_from_cache("clear_me"), undef, "fetching cleared item from cache"); >+ is( $cache->get_from_cache("dont_clear_me"), "I AM MORE DATA22", "fetching valid item from cache (after clearing another item)"); >+ >+ #test flushing from cache >+ $cache->set_in_cache("flush_me", "testing 1 data"); >+ $cache->flush_all; >+ is( $cache->get_from_cache("flush_me"), undef, "fetching flushed item from cache"); >+ is( $cache->get_from_cache("dont_clear_me"), undef, "fetching flushed item from cache"); >+} >-- >1.7.2.5
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 7248
:
6353
|
6354
|
6356
|
6359
|
6372
|
6771
|
6772
|
7342
|
7343
|
7366
|
7367
|
9348
|
9349
|
9352
|
9353
|
9360
|
9552
|
9553
|
9554
|
9555
|
9556
|
9567
|
9568
|
9569
|
9571