memcached-northscale 0.19.5.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,109 @@
1
+
2
+ require File.expand_path("#{File.dirname(__FILE__)}/../test_helper")
3
+
4
+ class RailsTest < Test::Unit::TestCase
5
+
6
+ def setup
7
+ @servers = ['127.0.0.1:43042', '127.0.0.1:43043', "#{UNIX_SOCKET_NAME}0"]
8
+ @namespace = 'rails_test'
9
+ @cache = Memcached::Rails.new(:servers => @servers, :namespace => @namespace)
10
+ @value = OpenStruct.new(:a => 1, :b => 2, :c => GenericClass)
11
+ @marshalled_value = Marshal.dump(@value)
12
+ end
13
+
14
+ def test_get
15
+ @cache.set key, @value
16
+ result = @cache.get key
17
+ assert_equal @value, result
18
+ end
19
+
20
+ def test_get_multi
21
+ @cache.set key, @value
22
+ result = @cache.get_multi([key])
23
+ assert_equal(
24
+ {key => @value},
25
+ result
26
+ )
27
+ end
28
+
29
+ def test_delete
30
+ @cache.set key, @value
31
+ assert_nothing_raised do
32
+ @cache.delete key
33
+ end
34
+ assert_nil(@cache.get(key))
35
+ end
36
+
37
+ def test_delete_missing
38
+ assert_nothing_raised do
39
+ @cache.delete key
40
+ assert_nil(@cache.delete(key))
41
+ end
42
+ end
43
+
44
+ def test_delete_with_two_arguments
45
+ assert_nothing_raised do
46
+ @cache.delete(key, 5)
47
+ assert_nil(@cache.get(key))
48
+ end
49
+ end
50
+
51
+ def test_bracket_accessors
52
+ @cache[key] = @value
53
+ result = @cache[key]
54
+ assert_equal @value, result
55
+ end
56
+
57
+ def test_cas
58
+ cache = Memcached::Rails.new(:servers => @servers, :namespace => @namespace, :support_cas => true)
59
+ value2 = OpenStruct.new(:d => 3, :e => 4, :f => GenericClass)
60
+
61
+ # Existing set
62
+ cache.set key, @value
63
+ cache.cas(key) do |current|
64
+ assert_equal @value, current
65
+ value2
66
+ end
67
+ assert_equal value2, cache.get(key)
68
+
69
+ # Missing set
70
+ cache.delete key
71
+ assert_nothing_raised do
72
+ cache.cas(key) { @called = true }
73
+ end
74
+ assert_nil cache.get(key)
75
+ assert_nil @called
76
+
77
+ # Conflicting set
78
+ cache.set key, @value
79
+ assert_raises(Memcached::ConnectionDataExists) do
80
+ cache.cas(key) do |current|
81
+ cache.set key, value2
82
+ current
83
+ end
84
+ end
85
+ end
86
+
87
+ def test_get_missing
88
+ @cache.delete key rescue nil
89
+ result = @cache.get key
90
+ assert_equal nil, result
91
+ end
92
+
93
+ def test_get_nil
94
+ @cache.set key, nil, 0
95
+ result = @cache.get key
96
+ assert_equal nil, result
97
+ end
98
+
99
+ def test_namespace
100
+ assert_equal @namespace, @cache.namespace
101
+ end
102
+
103
+ private
104
+
105
+ def key
106
+ caller.first[/.*[` ](.*)'/, 1] # '
107
+ end
108
+
109
+ end
metadata ADDED
@@ -0,0 +1,116 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: memcached-northscale
3
+ version: !ruby/object:Gem::Version
4
+ hash: 199
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 19
9
+ - 5
10
+ - 2
11
+ version: 0.19.5.2
12
+ platform: ruby
13
+ authors:
14
+ - Sean Lynch
15
+ autorequire:
16
+ bindir: bin
17
+ cert_chain: []
18
+
19
+ date: 2010-06-02 00:00:00 -07:00
20
+ default_executable:
21
+ dependencies: []
22
+
23
+ description: Test gem. Do not use unless you know what you're doing.
24
+ email: ""
25
+ executables: []
26
+
27
+ extensions:
28
+ - ext/extconf.rb
29
+ extra_rdoc_files:
30
+ - BENCHMARKS
31
+ - CHANGELOG
32
+ - LICENSE
33
+ - README
34
+ - TODO
35
+ - lib/memcached.rb
36
+ - lib/memcached/behaviors.rb
37
+ - lib/memcached/exceptions.rb
38
+ - lib/memcached/memcached.rb
39
+ - lib/memcached/rails.rb
40
+ files:
41
+ - BENCHMARKS
42
+ - CHANGELOG
43
+ - LICENSE
44
+ - Manifest
45
+ - README
46
+ - Rakefile
47
+ - TODO
48
+ - ext/extconf.rb
49
+ - ext/libmemcached-0.32.tar.gz
50
+ - ext/libmemcached.patch
51
+ - ext/rlibmemcached.i
52
+ - ext/rlibmemcached_wrap.c
53
+ - ext/sasl.patch
54
+ - lib/memcached.rb
55
+ - lib/memcached/auth.rb
56
+ - lib/memcached/behaviors.rb
57
+ - lib/memcached/exceptions.rb
58
+ - lib/memcached/integer.rb
59
+ - lib/memcached/memcached.rb
60
+ - lib/memcached/rails.rb
61
+ - test/profile/benchmark.rb
62
+ - test/profile/profile.rb
63
+ - test/profile/valgrind.rb
64
+ - test/setup.rb
65
+ - test/teardown.rb
66
+ - test/test_helper.rb
67
+ - test/unit/binding_test.rb
68
+ - test/unit/memcached_test.rb
69
+ - test/unit/rails_test.rb
70
+ - memcached-northscale.gemspec
71
+ has_rdoc: true
72
+ homepage: http://blog.evanweaver.com/files/doc/fauna/memcached/
73
+ licenses: []
74
+
75
+ post_install_message:
76
+ rdoc_options:
77
+ - --line-numbers
78
+ - --inline-source
79
+ - --title
80
+ - Memcached-northscale
81
+ - --main
82
+ - README
83
+ require_paths:
84
+ - lib
85
+ - ext
86
+ required_ruby_version: !ruby/object:Gem::Requirement
87
+ none: false
88
+ requirements:
89
+ - - ">="
90
+ - !ruby/object:Gem::Version
91
+ hash: 3
92
+ segments:
93
+ - 0
94
+ version: "0"
95
+ required_rubygems_version: !ruby/object:Gem::Requirement
96
+ none: false
97
+ requirements:
98
+ - - ">="
99
+ - !ruby/object:Gem::Version
100
+ hash: 11
101
+ segments:
102
+ - 1
103
+ - 2
104
+ version: "1.2"
105
+ requirements: []
106
+
107
+ rubyforge_project: northscale
108
+ rubygems_version: 1.3.7
109
+ signing_key:
110
+ specification_version: 3
111
+ summary: Test gem. Do not use unless you know what you're doing.
112
+ test_files:
113
+ - test/test_helper.rb
114
+ - test/unit/binding_test.rb
115
+ - test/unit/memcached_test.rb
116
+ - test/unit/rails_test.rb