fake_dynamo 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/fake_dynamo/attribute.rb +10 -0
- data/lib/fake_dynamo/filter.rb +7 -0
- data/lib/fake_dynamo/version.rb +1 -1
- data/spec/fake_dynamo/table_spec.rb +31 -0
- metadata +8 -8
@@ -14,6 +14,16 @@ module FakeDynamo
|
|
14
14
|
numeric(n)
|
15
15
|
end
|
16
16
|
end
|
17
|
+
|
18
|
+
if ['S', 'SS'].include? @type
|
19
|
+
Array(value).each do |v|
|
20
|
+
raise ValidationException, 'An AttributeValue may not contain an empty string' if v == ''
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
if name == ''
|
25
|
+
raise ValidationException, 'Empty attribute name'
|
26
|
+
end
|
17
27
|
end
|
18
28
|
|
19
29
|
def numeric(n)
|
data/lib/fake_dynamo/filter.rb
CHANGED
@@ -3,6 +3,7 @@ module FakeDynamo
|
|
3
3
|
include Validation
|
4
4
|
|
5
5
|
def comparison_filter(value_list, size, target_attribute, fail_on_type_mismatch, supported_types, comparator)
|
6
|
+
return false if target_attribute.nil?
|
6
7
|
|
7
8
|
validate_size(value_list, size)
|
8
9
|
|
@@ -66,6 +67,8 @@ module FakeDynamo
|
|
66
67
|
end
|
67
68
|
|
68
69
|
def contains_filter(value_list, target_attribute, fail_on_type_mismatch)
|
70
|
+
return false if target_attribute.nil?
|
71
|
+
|
69
72
|
validate_size(value_list, 1)
|
70
73
|
value_attribute = Attribute.from_hash(target_attribute.name, value_list.first)
|
71
74
|
validate_supported_types(value_attribute, ['N', 'S'])
|
@@ -78,6 +81,8 @@ module FakeDynamo
|
|
78
81
|
end
|
79
82
|
|
80
83
|
def not_contains_filter(value_list, target_attribute, fail_on_type_mismatch)
|
84
|
+
return false if target_attribute.nil?
|
85
|
+
|
81
86
|
validate_size(value_list, 1)
|
82
87
|
value_attribute = Attribute.from_hash(target_attribute.name, value_list.first)
|
83
88
|
validate_supported_types(value_attribute, ['N', 'S'])
|
@@ -92,6 +97,8 @@ module FakeDynamo
|
|
92
97
|
INF = 1.0/0.0
|
93
98
|
|
94
99
|
def in_filter(value_list, target_attribute, fail_on_type_mismatch)
|
100
|
+
return false if target_attribute.nil?
|
101
|
+
|
95
102
|
validate_size(value_list, (1..INF))
|
96
103
|
|
97
104
|
value_attribute_list = value_list.map do |value|
|
data/lib/fake_dynamo/version.rb
CHANGED
@@ -128,6 +128,37 @@ module FakeDynamo
|
|
128
128
|
end.to raise_error(ValidationException, /mismatch/i)
|
129
129
|
end
|
130
130
|
|
131
|
+
it 'should fail if the attribute value contains empty string' do
|
132
|
+
expect do
|
133
|
+
subject.put_item({ 'TableName' => 'Table1',
|
134
|
+
'Item' => {
|
135
|
+
'AttributeName1' => { 'S' => "test" },
|
136
|
+
'AttributeName2' => { 'N' => '11' },
|
137
|
+
'x' => { 'S' => '' }
|
138
|
+
}})
|
139
|
+
end.to raise_error(ValidationException, /empty/i)
|
140
|
+
|
141
|
+
expect do
|
142
|
+
subject.put_item({ 'TableName' => 'Table1',
|
143
|
+
'Item' => {
|
144
|
+
'AttributeName1' => { 'S' => "test" },
|
145
|
+
'AttributeName2' => { 'N' => '11' },
|
146
|
+
'x' => { 'SS' => ['x', ''] }
|
147
|
+
}})
|
148
|
+
end.to raise_error(ValidationException, /empty/i)
|
149
|
+
end
|
150
|
+
|
151
|
+
it 'should fail on empty key value' do
|
152
|
+
expect do
|
153
|
+
subject.put_item({ 'TableName' => 'Table1',
|
154
|
+
'Item' => {
|
155
|
+
'AttributeName1' => { 'S' => "test" },
|
156
|
+
'AttributeName2' => { 'N' => '11' },
|
157
|
+
'' => { 'SS' => ['x'] }
|
158
|
+
}})
|
159
|
+
end.to raise_error(ValidationException, /empty/i)
|
160
|
+
end
|
161
|
+
|
131
162
|
it 'should putitem in the table' do
|
132
163
|
subject.put_item(item)
|
133
164
|
subject.items.size.should == 1
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fake_dynamo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-03-
|
12
|
+
date: 2012-03-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: sinatra
|
16
|
-
requirement: &
|
16
|
+
requirement: &70299635734020 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70299635734020
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: activesupport
|
27
|
-
requirement: &
|
27
|
+
requirement: &70299635733520 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70299635733520
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: json
|
38
|
-
requirement: &
|
38
|
+
requirement: &70299635733020 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,7 +43,7 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70299635733020
|
47
47
|
description:
|
48
48
|
email:
|
49
49
|
- ananthakumaran@gmail.com
|