fake_dynamo 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +1 -1
- data/lib/fake_dynamo/api.yml +90 -0
- data/lib/fake_dynamo/attribute.rb +20 -4
- data/lib/fake_dynamo/filter.rb +21 -17
- data/lib/fake_dynamo/item.rb +2 -2
- data/lib/fake_dynamo/validation.rb +2 -0
- data/lib/fake_dynamo/version.rb +1 -1
- data/lib/fake_dynamo.rb +1 -0
- data/spec/fake_dynamo/filter_spec.rb +27 -0
- data/spec/fake_dynamo/server_spec.rb +1 -10
- data/spec/fake_dynamo/storage_spec.rb +3 -1
- data/spec/fake_dynamo/table_spec.rb +3 -1
- metadata +8 -8
data/README.md
CHANGED
@@ -25,9 +25,9 @@ fake_dynamo --port 4567
|
|
25
25
|
* aws-sdk
|
26
26
|
|
27
27
|
````ruby
|
28
|
-
# rvmsudo fake_dynamo --port 80
|
29
28
|
AWS.config(:use_ssl => false,
|
30
29
|
:dynamo_db_endpoint => 'localhost',
|
30
|
+
:dynamo_db_port => 4567,
|
31
31
|
:access_key_id => "xxx",
|
32
32
|
:secret_access_key => "xxx")
|
33
33
|
````
|
data/lib/fake_dynamo/api.yml
CHANGED
@@ -28,12 +28,17 @@
|
|
28
28
|
- :string
|
29
29
|
N:
|
30
30
|
- :string
|
31
|
+
B:
|
32
|
+
- :blob
|
31
33
|
SS:
|
32
34
|
- :list:
|
33
35
|
- :string
|
34
36
|
NS:
|
35
37
|
- :list:
|
36
38
|
- :string
|
39
|
+
BS:
|
40
|
+
- :list:
|
41
|
+
- :blob
|
37
42
|
- :required
|
38
43
|
RangeKeyElement:
|
39
44
|
- :structure:
|
@@ -41,12 +46,17 @@
|
|
41
46
|
- :string
|
42
47
|
N:
|
43
48
|
- :string
|
49
|
+
B:
|
50
|
+
- :blob
|
44
51
|
SS:
|
45
52
|
- :list:
|
46
53
|
- :string
|
47
54
|
NS:
|
48
55
|
- :list:
|
49
56
|
- :string
|
57
|
+
BS:
|
58
|
+
- :list:
|
59
|
+
- :blob
|
50
60
|
- :required
|
51
61
|
AttributesToGet:
|
52
62
|
- :list:
|
@@ -84,12 +94,17 @@
|
|
84
94
|
- :string
|
85
95
|
N:
|
86
96
|
- :string
|
97
|
+
B:
|
98
|
+
- :blob
|
87
99
|
SS:
|
88
100
|
- :list:
|
89
101
|
- :string
|
90
102
|
NS:
|
91
103
|
- :list:
|
92
104
|
- :string
|
105
|
+
BS:
|
106
|
+
- :list:
|
107
|
+
- :blob
|
93
108
|
- :required
|
94
109
|
RangeKeyElement:
|
95
110
|
- :structure:
|
@@ -97,12 +112,17 @@
|
|
97
112
|
- :string
|
98
113
|
N:
|
99
114
|
- :string
|
115
|
+
B:
|
116
|
+
- :blob
|
100
117
|
SS:
|
101
118
|
- :list:
|
102
119
|
- :string
|
103
120
|
NS:
|
104
121
|
- :list:
|
105
122
|
- :string
|
123
|
+
BS:
|
124
|
+
- :list:
|
125
|
+
- :blob
|
106
126
|
- :required
|
107
127
|
AttributesToGet:
|
108
128
|
- :list:
|
@@ -170,12 +190,17 @@
|
|
170
190
|
- :string
|
171
191
|
N:
|
172
192
|
- :string
|
193
|
+
B:
|
194
|
+
- :blob
|
173
195
|
SS:
|
174
196
|
- :list:
|
175
197
|
- :string
|
176
198
|
NS:
|
177
199
|
- :list:
|
178
200
|
- :string
|
201
|
+
BS:
|
202
|
+
- :list:
|
203
|
+
- :blob
|
179
204
|
- :required
|
180
205
|
Expected:
|
181
206
|
- :map:
|
@@ -189,12 +214,17 @@
|
|
189
214
|
- :string
|
190
215
|
N:
|
191
216
|
- :string
|
217
|
+
B:
|
218
|
+
- :blob
|
192
219
|
SS:
|
193
220
|
- :list:
|
194
221
|
- :string
|
195
222
|
NS:
|
196
223
|
- :list:
|
197
224
|
- :string
|
225
|
+
BS:
|
226
|
+
- :list:
|
227
|
+
- :blob
|
198
228
|
Exists:
|
199
229
|
- :boolean
|
200
230
|
ReturnValues:
|
@@ -301,12 +331,17 @@
|
|
301
331
|
- :string
|
302
332
|
N:
|
303
333
|
- :string
|
334
|
+
B:
|
335
|
+
- :blob
|
304
336
|
SS:
|
305
337
|
- :list:
|
306
338
|
- :string
|
307
339
|
NS:
|
308
340
|
- :list:
|
309
341
|
- :string
|
342
|
+
BS:
|
343
|
+
- :list:
|
344
|
+
- :blob
|
310
345
|
- :required
|
311
346
|
RangeKeyElement:
|
312
347
|
- :structure:
|
@@ -314,12 +349,17 @@
|
|
314
349
|
- :string
|
315
350
|
N:
|
316
351
|
- :string
|
352
|
+
B:
|
353
|
+
- :blob
|
317
354
|
SS:
|
318
355
|
- :list:
|
319
356
|
- :string
|
320
357
|
NS:
|
321
358
|
- :list:
|
322
359
|
- :string
|
360
|
+
BS:
|
361
|
+
- :list:
|
362
|
+
- :blob
|
323
363
|
- :required
|
324
364
|
AttributeUpdates:
|
325
365
|
- :map:
|
@@ -549,12 +589,17 @@
|
|
549
589
|
- :string
|
550
590
|
N:
|
551
591
|
- :string
|
592
|
+
B:
|
593
|
+
- :blob
|
552
594
|
SS:
|
553
595
|
- :list:
|
554
596
|
- :string
|
555
597
|
NS:
|
556
598
|
- :list:
|
557
599
|
- :string
|
600
|
+
BS:
|
601
|
+
- :list:
|
602
|
+
- :blob
|
558
603
|
ComparisonOperator:
|
559
604
|
- :string
|
560
605
|
- :required
|
@@ -567,12 +612,17 @@
|
|
567
612
|
- :string
|
568
613
|
N:
|
569
614
|
- :string
|
615
|
+
B:
|
616
|
+
- :blob
|
570
617
|
SS:
|
571
618
|
- :list:
|
572
619
|
- :string
|
573
620
|
NS:
|
574
621
|
- :list:
|
575
622
|
- :string
|
623
|
+
BS:
|
624
|
+
- :list:
|
625
|
+
- :blob
|
576
626
|
- :required
|
577
627
|
RangeKeyElement:
|
578
628
|
- :structure:
|
@@ -580,12 +630,17 @@
|
|
580
630
|
- :string
|
581
631
|
N:
|
582
632
|
- :string
|
633
|
+
B:
|
634
|
+
- :blob
|
583
635
|
SS:
|
584
636
|
- :list:
|
585
637
|
- :string
|
586
638
|
NS:
|
587
639
|
- :list:
|
588
640
|
- :string
|
641
|
+
BS:
|
642
|
+
- :list:
|
643
|
+
- :blob
|
589
644
|
:output:
|
590
645
|
- Items:
|
591
646
|
- :list: member
|
@@ -638,12 +693,17 @@
|
|
638
693
|
- :string
|
639
694
|
N:
|
640
695
|
- :string
|
696
|
+
B:
|
697
|
+
- :blob
|
641
698
|
SS:
|
642
699
|
- :list:
|
643
700
|
- :string
|
644
701
|
NS:
|
645
702
|
- :list:
|
646
703
|
- :string
|
704
|
+
BS:
|
705
|
+
- :list:
|
706
|
+
- :blob
|
647
707
|
- :required
|
648
708
|
RangeKeyCondition:
|
649
709
|
- :structure:
|
@@ -654,12 +714,17 @@
|
|
654
714
|
- :string
|
655
715
|
N:
|
656
716
|
- :string
|
717
|
+
B:
|
718
|
+
- :blob
|
657
719
|
SS:
|
658
720
|
- :list:
|
659
721
|
- :string
|
660
722
|
NS:
|
661
723
|
- :list:
|
662
724
|
- :string
|
725
|
+
BS:
|
726
|
+
- :list:
|
727
|
+
- :blob
|
663
728
|
ComparisonOperator:
|
664
729
|
- :string
|
665
730
|
- :required
|
@@ -674,12 +739,17 @@
|
|
674
739
|
- :string
|
675
740
|
N:
|
676
741
|
- :string
|
742
|
+
B:
|
743
|
+
- :blob
|
677
744
|
SS:
|
678
745
|
- :list:
|
679
746
|
- :string
|
680
747
|
NS:
|
681
748
|
- :list:
|
682
749
|
- :string
|
750
|
+
BS:
|
751
|
+
- :list:
|
752
|
+
- :blob
|
683
753
|
- :required
|
684
754
|
RangeKeyElement:
|
685
755
|
- :structure:
|
@@ -687,12 +757,17 @@
|
|
687
757
|
- :string
|
688
758
|
N:
|
689
759
|
- :string
|
760
|
+
B:
|
761
|
+
- :blob
|
690
762
|
SS:
|
691
763
|
- :list:
|
692
764
|
- :string
|
693
765
|
NS:
|
694
766
|
- :list:
|
695
767
|
- :string
|
768
|
+
BS:
|
769
|
+
- :list:
|
770
|
+
- :blob
|
696
771
|
:output:
|
697
772
|
- Items:
|
698
773
|
- :list: member
|
@@ -743,12 +818,17 @@
|
|
743
818
|
- :string
|
744
819
|
N:
|
745
820
|
- :string
|
821
|
+
B:
|
822
|
+
- :blob
|
746
823
|
SS:
|
747
824
|
- :list:
|
748
825
|
- :string
|
749
826
|
NS:
|
750
827
|
- :list:
|
751
828
|
- :string
|
829
|
+
BS:
|
830
|
+
- :list:
|
831
|
+
- :blob
|
752
832
|
- :required
|
753
833
|
DeleteRequest:
|
754
834
|
- :structure:
|
@@ -760,12 +840,17 @@
|
|
760
840
|
- :string
|
761
841
|
N:
|
762
842
|
- :string
|
843
|
+
B:
|
844
|
+
- :blob
|
763
845
|
SS:
|
764
846
|
- :list:
|
765
847
|
- :string
|
766
848
|
NS:
|
767
849
|
- :list:
|
768
850
|
- :string
|
851
|
+
BS:
|
852
|
+
- :list:
|
853
|
+
- :blob
|
769
854
|
- :required
|
770
855
|
RangeKeyElement:
|
771
856
|
- :structure:
|
@@ -773,12 +858,17 @@
|
|
773
858
|
- :string
|
774
859
|
N:
|
775
860
|
- :string
|
861
|
+
B:
|
862
|
+
- :blob
|
776
863
|
SS:
|
777
864
|
- :list:
|
778
865
|
- :string
|
779
866
|
NS:
|
780
867
|
- :list:
|
781
868
|
- :string
|
869
|
+
BS:
|
870
|
+
- :list:
|
871
|
+
- :blob
|
782
872
|
- :required
|
783
873
|
- :required
|
784
874
|
:output:
|
@@ -5,7 +5,15 @@ module FakeDynamo
|
|
5
5
|
def initialize(name, value, type)
|
6
6
|
@name, @value, @type = name, value, type
|
7
7
|
|
8
|
-
if
|
8
|
+
if @type == 'B'
|
9
|
+
@value = Base64.decode64(value)
|
10
|
+
end
|
11
|
+
|
12
|
+
if @type == 'BS'
|
13
|
+
@value = value.map { |v| Base64.decode64(v) }
|
14
|
+
end
|
15
|
+
|
16
|
+
if ['NS', 'SS', 'BS'].include? @type
|
9
17
|
raise ValidationException, 'An AttributeValue may not contain an empty set' if value.empty?
|
10
18
|
raise ValidationException, 'Input collection contains duplicates' if value.uniq!
|
11
19
|
end
|
@@ -16,9 +24,9 @@ module FakeDynamo
|
|
16
24
|
end
|
17
25
|
end
|
18
26
|
|
19
|
-
if ['S', 'SS'].include? @type
|
27
|
+
if ['S', 'SS', 'S', 'BS'].include? @type
|
20
28
|
Array(value).each do |v|
|
21
|
-
raise ValidationException, 'An AttributeValue may not contain an empty string' if v == ''
|
29
|
+
raise ValidationException, 'An AttributeValue may not contain an empty string or empty binary' if v == ''
|
22
30
|
end
|
23
31
|
end
|
24
32
|
|
@@ -43,7 +51,15 @@ module FakeDynamo
|
|
43
51
|
end
|
44
52
|
|
45
53
|
def as_hash
|
46
|
-
|
54
|
+
value = if @type == 'B'
|
55
|
+
Base64.encode64(@value)
|
56
|
+
elsif @type == 'BS'
|
57
|
+
@value.map { |v| Base64.encode64(v) }
|
58
|
+
else
|
59
|
+
@value
|
60
|
+
end
|
61
|
+
|
62
|
+
{ @name => { @type => value } }
|
47
63
|
end
|
48
64
|
|
49
65
|
def ==(attribute)
|
data/lib/fake_dynamo/filter.rb
CHANGED
@@ -49,14 +49,14 @@ module FakeDynamo
|
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
52
|
-
def_filter(:eq, 1, ['N', 'S'], &:==)
|
53
|
-
def_filter(:le, 1, ['N', 'S'], &:<=)
|
54
|
-
def_filter(:lt, 1, ['N', 'S'], &:<)
|
55
|
-
def_filter(:ge, 1, ['N', 'S'], &:>=)
|
56
|
-
def_filter(:gt, 1, ['N', 'S'], &:>)
|
57
|
-
def_filter(:begins_with, 1, ['S'], &:start_with?)
|
58
|
-
def_filter(:between, 2, ['N', 'S'], &:between?)
|
59
|
-
def_filter(:ne, 1, ['N', 'S'], &:!=)
|
52
|
+
def_filter(:eq, 1, ['N', 'S', 'B'], &:==)
|
53
|
+
def_filter(:le, 1, ['N', 'S', 'B'], &:<=)
|
54
|
+
def_filter(:lt, 1, ['N', 'S', 'B'], &:<)
|
55
|
+
def_filter(:ge, 1, ['N', 'S', 'B'], &:>=)
|
56
|
+
def_filter(:gt, 1, ['N', 'S', 'B'], &:>)
|
57
|
+
def_filter(:begins_with, 1, ['S', 'B'], &:start_with?)
|
58
|
+
def_filter(:between, 2, ['N', 'S', 'B'], &:between?)
|
59
|
+
def_filter(:ne, 1, ['N', 'S', 'B'], &:!=)
|
60
60
|
|
61
61
|
def not_null_filter(value_list, target_attribute, fail_on_type_mismatch)
|
62
62
|
not target_attribute.nil?
|
@@ -66,16 +66,22 @@ module FakeDynamo
|
|
66
66
|
target_attribute.nil?
|
67
67
|
end
|
68
68
|
|
69
|
+
def comparable_types?(value_type, target_type)
|
70
|
+
((value_type == 'S' and
|
71
|
+
(target_type == 'S' or target_type == 'SS')) or
|
72
|
+
(value_type == 'N' and target_type == 'NS') or
|
73
|
+
(value_type == 'B' and
|
74
|
+
(target_type == 'B' or target_type == 'BS')))
|
75
|
+
end
|
76
|
+
|
69
77
|
def contains_filter(value_list, target_attribute, fail_on_type_mismatch)
|
70
78
|
return false if target_attribute.nil?
|
71
79
|
|
72
80
|
validate_size(value_list, 1)
|
73
81
|
value_attribute = Attribute.from_hash(target_attribute.name, value_list.first)
|
74
|
-
validate_supported_types(value_attribute, ['N', 'S'])
|
82
|
+
validate_supported_types(value_attribute, ['N', 'S', 'B'])
|
75
83
|
|
76
|
-
if (
|
77
|
-
(target_attribute.type == 'S' or target_attribute.type == 'SS')) or
|
78
|
-
(value_attribute.type == 'N' and target_attribute.type == 'NS'))
|
84
|
+
if comparable_types?(value_attribute.type, target_attribute.type)
|
79
85
|
target_attribute.value.include?(value_attribute.value)
|
80
86
|
end
|
81
87
|
end
|
@@ -85,11 +91,9 @@ module FakeDynamo
|
|
85
91
|
|
86
92
|
validate_size(value_list, 1)
|
87
93
|
value_attribute = Attribute.from_hash(target_attribute.name, value_list.first)
|
88
|
-
validate_supported_types(value_attribute, ['N', 'S'])
|
94
|
+
validate_supported_types(value_attribute, ['N', 'S', 'B'])
|
89
95
|
|
90
|
-
if (
|
91
|
-
(target_attribute.type == 'S' or target_attribute.type == 'SS')) or
|
92
|
-
(value_attribute.type == 'N' and target_attribute.type == 'NS'))
|
96
|
+
if comparable_types?(value_attribute.type, target_attribute.type)
|
93
97
|
!target_attribute.value.include?(value_attribute.value)
|
94
98
|
end
|
95
99
|
end
|
@@ -103,7 +107,7 @@ module FakeDynamo
|
|
103
107
|
|
104
108
|
value_attribute_list = value_list.map do |value|
|
105
109
|
value_attribute = Attribute.from_hash(target_attribute.name, value)
|
106
|
-
validate_supported_types(value_attribute, ['N', 'S'])
|
110
|
+
validate_supported_types(value_attribute, ['N', 'S', 'B'])
|
107
111
|
value_attribute
|
108
112
|
end
|
109
113
|
|
data/lib/fake_dynamo/item.rb
CHANGED
@@ -71,7 +71,7 @@ module FakeDynamo
|
|
71
71
|
attributes.delete(name)
|
72
72
|
elsif old_attribute = attributes[name]
|
73
73
|
validate_type(value, old_attribute)
|
74
|
-
unless ["SS", "NS"].include? old_attribute.type
|
74
|
+
unless ["SS", "NS", "BS"].include? old_attribute.type
|
75
75
|
raise ValidationException, "Action DELETE is not supported for type #{old_attribute.type}"
|
76
76
|
end
|
77
77
|
attribute = Attribute.from_hash(name, value)
|
@@ -82,7 +82,7 @@ module FakeDynamo
|
|
82
82
|
def add(name, value)
|
83
83
|
attribute = Attribute.from_hash(name, value)
|
84
84
|
|
85
|
-
unless ["N", "SS", "NS"].include? attribute.type
|
85
|
+
unless ["N", "SS", "NS", "BS"].include? attribute.type
|
86
86
|
raise ValidationException, "Action ADD is not supported for type #{attribute.type}"
|
87
87
|
end
|
88
88
|
|
@@ -52,6 +52,8 @@ module FakeDynamo
|
|
52
52
|
case constrain
|
53
53
|
when :string
|
54
54
|
add_errors("The parameter '#{param(attribute, parents)}' must be a string") unless data.kind_of? String
|
55
|
+
when :blob
|
56
|
+
add_errors("The parameter '#{param(attribute, parents)}' must be a binary") unless data.kind_of? String
|
55
57
|
when :long
|
56
58
|
add_errors("The parameter '#{param(attribute, parents)}' must be a long") unless data.kind_of? Integer
|
57
59
|
when :integer
|
data/lib/fake_dynamo/version.rb
CHANGED
data/lib/fake_dynamo.rb
CHANGED
@@ -6,17 +6,27 @@ module FakeDynamo
|
|
6
6
|
include Filter
|
7
7
|
end
|
8
8
|
|
9
|
+
|
9
10
|
describe Filter do
|
11
|
+
|
12
|
+
def encode(bytes)
|
13
|
+
Base64.encode64(bytes.pack('c*'))
|
14
|
+
end
|
15
|
+
|
10
16
|
subject { FilterTest.new }
|
11
17
|
|
18
|
+
let(:bstr) { encode([1, 2, 3]) }
|
12
19
|
let(:s_attr) { Attribute.new('test', 'bcd', 'S')}
|
13
20
|
let(:ss_attr) { Attribute.new('test', ['ab', 'cd'], 'SS') }
|
14
21
|
let(:n_attr) { Attribute.new('test', '10', 'N')}
|
15
22
|
let(:ns_attr) { Attribute.new('test', ['1', '2', '3', '4'], 'NS')}
|
23
|
+
let(:b_attr) { Attribute.new('test', bstr, 'B')}
|
24
|
+
let(:bs_attr) { Attribute.new('test', [bstr], 'BS')}
|
16
25
|
|
17
26
|
|
18
27
|
it 'tests eq' do
|
19
28
|
subject.eq_filter([{'S' => 'bcd'}], s_attr, false).should be_true
|
29
|
+
subject.eq_filter([{'B' => bstr}], b_attr, false).should be_true
|
20
30
|
subject.eq_filter([{'S' => '10'}], n_attr, false).should be_false
|
21
31
|
expect { subject.eq_filter([{'S' => '10'}], n_attr, true) }.to raise_error(ValidationException, /mismatch/)
|
22
32
|
end
|
@@ -28,6 +38,8 @@ module FakeDynamo
|
|
28
38
|
subject.le_filter([{'N' => '10'}], n_attr, false).should be_true
|
29
39
|
subject.le_filter([{'N' => '11'}], n_attr, false).should be_true
|
30
40
|
subject.le_filter([{'N' => '1'}], n_attr, false).should be_false
|
41
|
+
subject.le_filter([{'B' => encode([1, 1])}], b_attr, false).should be_false
|
42
|
+
subject.le_filter([{'B' => encode([1, 2, 3])}], b_attr, false).should be_true
|
31
43
|
end
|
32
44
|
|
33
45
|
it 'tests lt' do
|
@@ -37,6 +49,9 @@ module FakeDynamo
|
|
37
49
|
subject.lt_filter([{'N' => '10'}], n_attr, false).should be_false
|
38
50
|
subject.lt_filter([{'N' => '11'}], n_attr, false).should be_true
|
39
51
|
subject.lt_filter([{'N' => '1'}], n_attr, false).should be_false
|
52
|
+
subject.lt_filter([{'B' => encode([1, 2])}], b_attr, false).should be_false
|
53
|
+
subject.lt_filter([{'B' => encode([1, 4])}], b_attr, false).should be_true
|
54
|
+
subject.lt_filter([{'B' => encode([1, 2, 3])}], b_attr, false).should be_false
|
40
55
|
end
|
41
56
|
|
42
57
|
it 'test ge' do
|
@@ -46,6 +61,8 @@ module FakeDynamo
|
|
46
61
|
subject.ge_filter([{'N' => '10'}], n_attr, false).should be_true
|
47
62
|
subject.ge_filter([{'N' => '11'}], n_attr, false).should be_false
|
48
63
|
subject.ge_filter([{'N' => '1'}], n_attr, false).should be_true
|
64
|
+
subject.ge_filter([{'B' => encode([1, 1])}], b_attr, false).should be_true
|
65
|
+
subject.ge_filter([{'B' => encode([1, 2, 3])}], b_attr, false).should be_true
|
49
66
|
end
|
50
67
|
|
51
68
|
it 'test gt' do
|
@@ -55,11 +72,15 @@ module FakeDynamo
|
|
55
72
|
subject.gt_filter([{'N' => '10'}], n_attr, false).should be_false
|
56
73
|
subject.gt_filter([{'N' => '11'}], n_attr, false).should be_false
|
57
74
|
subject.gt_filter([{'N' => '1'}], n_attr, false).should be_true
|
75
|
+
subject.gt_filter([{'B' => encode([1, 1])}], b_attr, false).should be_true
|
76
|
+
subject.gt_filter([{'B' => encode([1, 2, 3])}], b_attr, false).should be_false
|
58
77
|
end
|
59
78
|
|
60
79
|
it 'test begins_with' do
|
61
80
|
subject.begins_with_filter([{'S' => 'bc'}], s_attr, false).should be_true
|
62
81
|
subject.begins_with_filter([{'S' => 'cd'}], s_attr, false).should be_false
|
82
|
+
subject.begins_with_filter([{'B' => encode([1, 1])}], b_attr, false).should be_false
|
83
|
+
subject.begins_with_filter([{'B' => encode([1, 2])}], b_attr, false).should be_true
|
63
84
|
expect {
|
64
85
|
subject.begins_with_filter([{'N' => '10'}], n_attr, false)
|
65
86
|
}.to raise_error(ValidationException, /not supported/)
|
@@ -73,6 +94,8 @@ module FakeDynamo
|
|
73
94
|
subject.between_filter([{'S' => 'bcd'},{'S' => 'bcd'}], s_attr, false).should be_true
|
74
95
|
subject.between_filter([{'N' => '9'},{'N' => '11'}], n_attr, false).should be_true
|
75
96
|
subject.between_filter([{'S' => '9'},{'S' => '11'}], n_attr, false).should be_false
|
97
|
+
subject.between_filter([{'B' => encode([1, 1])}, {'B' => encode([1, 2])}], b_attr, false).should be_false
|
98
|
+
subject.between_filter([{'B' => encode([1, 2, 2])}, {'B' => encode([1, 2, 4])}], b_attr, false).should be_true
|
76
99
|
end
|
77
100
|
|
78
101
|
it 'test ne' do
|
@@ -80,6 +103,7 @@ module FakeDynamo
|
|
80
103
|
subject.ne_filter([{'S' => '10'}], n_attr, false).should be_false
|
81
104
|
subject.ne_filter([{'S' => 'xx'}], s_attr, false).should be_true
|
82
105
|
subject.ne_filter([{'S' => '10'}], n_attr, false).should be_false
|
106
|
+
subject.ne_filter([{'B' => bstr}], b_attr, false).should be_false
|
83
107
|
end
|
84
108
|
|
85
109
|
it 'test not null' do
|
@@ -97,6 +121,7 @@ module FakeDynamo
|
|
97
121
|
subject.contains_filter([{'S' => 'cd'}], ss_attr, false).should be_true
|
98
122
|
subject.contains_filter([{'N' => '2'}], ns_attr, false).should be_true
|
99
123
|
subject.contains_filter([{'N' => '10'}], n_attr, false).should be_false
|
124
|
+
subject.contains_filter([{'B' => encode([1])}], b_attr, false).should be_true
|
100
125
|
end
|
101
126
|
|
102
127
|
it 'test not contains' do
|
@@ -106,6 +131,7 @@ module FakeDynamo
|
|
106
131
|
subject.not_contains_filter([{'N' => '2'}], ns_attr, false).should be_false
|
107
132
|
subject.not_contains_filter([{'N' => '12'}], ns_attr, false).should be_true
|
108
133
|
subject.not_contains_filter([{'N' => '10'}], n_attr, false).should be_false
|
134
|
+
subject.not_contains_filter([{'B' => encode([1])}], b_attr, false).should be_false
|
109
135
|
end
|
110
136
|
|
111
137
|
it 'test in' do
|
@@ -113,6 +139,7 @@ module FakeDynamo
|
|
113
139
|
subject.in_filter([{'S' => 'bcd'}, {'N' => '10'}], n_attr, true).should be_true
|
114
140
|
subject.in_filter([{'N' => '1'}], ns_attr, true).should be_false
|
115
141
|
subject.in_filter([{'S' => 'xx'}], s_attr, false).should be_false
|
142
|
+
subject.in_filter([{'B' => encode([1, 2, 3])}], b_attr, false).should be_true
|
116
143
|
end
|
117
144
|
end
|
118
145
|
end
|
@@ -4,15 +4,6 @@ module FakeDynamo
|
|
4
4
|
describe Server do
|
5
5
|
include Rack::Test::Methods
|
6
6
|
|
7
|
-
def get_server(app)
|
8
|
-
s = app.instance_variable_get :@app
|
9
|
-
if s.instance_of? Server
|
10
|
-
s
|
11
|
-
else
|
12
|
-
get_server(s)
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
7
|
let(:data) do
|
17
8
|
{
|
18
9
|
"TableName" => "Table1",
|
@@ -23,7 +14,7 @@ module FakeDynamo
|
|
23
14
|
}
|
24
15
|
end
|
25
16
|
let(:app) { Server.new }
|
26
|
-
let(:server) {
|
17
|
+
let(:server) { Server.new! }
|
27
18
|
|
28
19
|
it "should extract_operation" do
|
29
20
|
server.extract_operation('HTTP_X_AMZ_TARGET' => 'DynamoDB_20111205.CreateTable').should eq('CreateTable')
|
@@ -15,7 +15,9 @@ module FakeDynamo
|
|
15
15
|
def item(i)
|
16
16
|
{'TableName' => 'User',
|
17
17
|
'Item' => { 'id' => { 'S' => (i % 100).to_s },
|
18
|
-
'name' => { 'S' => "╩tr¥in" }
|
18
|
+
'name' => { 'S' => "╩tr¥in" },
|
19
|
+
'binary' => { 'B' => Base64.encode64("binary") },
|
20
|
+
'binary' => { 'BS' => [Base64.encode64("binary")] }}
|
19
21
|
}
|
20
22
|
end
|
21
23
|
|
@@ -18,7 +18,9 @@ module FakeDynamo
|
|
18
18
|
'Item' => {
|
19
19
|
'AttributeName1' => { 'S' => "test" },
|
20
20
|
'AttributeName2' => { 'N' => '11' },
|
21
|
-
'AttributeName3' => { 'S' => "another" }
|
21
|
+
'AttributeName3' => { 'S' => "another" },
|
22
|
+
'binary' => { 'B' => Base64.encode64("binary") },
|
23
|
+
'binary_set' => { 'BS' => [Base64.encode64("binary")] }
|
22
24
|
}}
|
23
25
|
end
|
24
26
|
|
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.1.
|
4
|
+
version: 0.1.1
|
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-
|
12
|
+
date: 2012-11-11 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: sinatra
|
16
|
-
requirement: &
|
16
|
+
requirement: &70342224155740 !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: *70342224155740
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: activesupport
|
27
|
-
requirement: &
|
27
|
+
requirement: &70342224155280 !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: *70342224155280
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: json
|
38
|
-
requirement: &
|
38
|
+
requirement: &70342224154860 !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: *70342224154860
|
47
47
|
description:
|
48
48
|
email:
|
49
49
|
- ananthakumaran@gmail.com
|