|
9 | 9 | expect { subject }
|
10 | 10 | .to raise_error(
|
11 | 11 | Floe::InvalidWorkflowError,
|
12 |
| - "Map.ItemBatcher must have one of \"MaxItemsPerBatch\", \"MaxItemsPerBatchPath\", \"MaxInputBytesPerBatch\", \"MaxInputBytesPerBatchPath\"" |
| 12 | + "Map.ItemBatcher must have one of \"MaxItemsPerBatch\", \"MaxItemsPerBatchPath\"" |
13 | 13 | )
|
14 | 14 | end
|
15 | 15 | end
|
|
50 | 50 | let(:payload) { {"MaxInputBytesPerBatch" => 1_024} }
|
51 | 51 |
|
52 | 52 | it "returns an ItemBatcher" do
|
| 53 | + pending "implement MaxInputBytesPerBatch" |
53 | 54 | expect(subject).to be_kind_of(described_class)
|
54 | 55 | end
|
55 | 56 |
|
56 | 57 | it "sets max_input_bytes_per_batch" do
|
| 58 | + pending "implement MaxInputBytesPerBatch" |
| 59 | + |
57 | 60 | expect(subject.max_input_bytes_per_batch).to eq(payload["MaxInputBytesPerBatch"])
|
58 | 61 | end
|
59 | 62 |
|
60 | 63 | context "that is an invalid value" do
|
61 | 64 | let(:payload) { {"MaxInputBytesPerBatch" => 0} }
|
62 | 65 |
|
63 | 66 | it "raises an exception" do
|
| 67 | + pending "implement MaxInputBytesPerBatch" |
| 68 | + |
64 | 69 | expect { subject }.to raise_error(Floe::InvalidWorkflowError, "Map.ItemBatcher field \"MaxInputBytesPerBatch\" value \"0\" must be a positive integer")
|
65 | 70 | end
|
66 | 71 | end
|
|
83 | 88 | let(:payload) { {"MaxInputBytesPerBatchPath" => "$.batchSize"} }
|
84 | 89 |
|
85 | 90 | it "returns an ItemBatcher" do
|
| 91 | + pending "implement MaxInputBytesPerBatchPath" |
| 92 | + |
86 | 93 | expect(subject).to be_kind_of(described_class)
|
87 | 94 | end
|
88 | 95 |
|
89 | 96 | it "sets max_input_bytes_per_batch_path" do
|
| 97 | + pending "implement MaxInputBytesPerBatchPath" |
| 98 | + |
90 | 99 | expect(subject.max_input_bytes_per_batch_path).to be_kind_of(Floe::Workflow::ReferencePath)
|
91 | 100 | expect(subject.max_input_bytes_per_batch_path).to have_attributes(:path => ["batchSize"])
|
92 | 101 | end
|
|
104 | 113 | let(:payload) { {"MaxInputBytesPerBatch" => 1_024, "MaxInputBytesPerBatchPath" => "$.batchSize"} }
|
105 | 114 |
|
106 | 115 | it "raises an exception" do
|
| 116 | + pending "implement MaxInputBytesPerBatchPath" |
| 117 | + |
107 | 118 | expect { subject }.to raise_error(Floe::InvalidWorkflowError, "Map.ItemBatcher must not specify both \"MaxInputBytesPerBatch\" and \"MaxInputBytesPerBatchPath\"")
|
108 | 119 | end
|
109 | 120 | end
|
|
139 | 150 | end
|
140 | 151 | end
|
141 | 152 |
|
| 153 | + context "with MaxInputBytesPerBatch" do |
| 154 | + let(:payload) { {"MaxInputBytesPerBatch" => 1_024} } |
| 155 | + |
| 156 | + it "returns in batches of 2" do |
| 157 | + pending "support max bytes per batch" |
| 158 | + |
| 159 | + expect(subject.value(context, input)).to eq([{"Items" => %w[a b]}, {"Items" => %w[c d]}, {"Items" => %w[e]}]) |
| 160 | + end |
| 161 | + end |
| 162 | + |
| 163 | + context "with MaxInputBytesPerBatchPath" do |
| 164 | + let(:payload) { {"MaxInputBytesPerBatchPath" => "$.bytesPerBatch"} } |
| 165 | + let(:state_input) { {"bytesPerBatch" => 1_024, "items" => input} } |
| 166 | + |
| 167 | + it "returns in batches of 2" do |
| 168 | + pending "support max bytes per batch" |
| 169 | + |
| 170 | + expect(subject.value(context, input, state_input)).to eq([{"Items" => %w[a b]}, {"Items" => %w[c d]}, {"Items" => %w[e]}]) |
| 171 | + end |
| 172 | + |
| 173 | + context "with an invalid value in input" do |
| 174 | + let(:state_input) { {"bytesPerBatch" => 0, "items" => input} } |
| 175 | + |
| 176 | + it "raises an exception" do |
| 177 | + pending "support max bytes per batch" |
| 178 | + |
| 179 | + expect { subject.value(context, input, state_input) } |
| 180 | + .to raise_error(Floe::ExecutionError, "Map.ItemBatcher field \"MaxInputBytesPerBatchPath\" value \"0\" must be a positive integer") |
| 181 | + end |
| 182 | + end |
| 183 | + end |
| 184 | + |
142 | 185 | context "with BatchInput" do
|
143 | 186 | let(:payload) { {"BatchInput" => {"foo.$" => "$.bar"}, "MaxItemsPerBatch" => 2} }
|
144 | 187 | let(:state_input) { {"bar" => "bar", "items" => input} }
|
|
0 commit comments