|
37 | 37 | )
|
38 | 38 |
|
39 | 39 | var _ = Describe("Cast", func() {
|
| 40 | + Describe("Validate", func() { |
| 41 | + Context("with a nil cast", func() { |
| 42 | + It("fails", func() { |
| 43 | + isValid, err := cast.Validate(nil) |
| 44 | + |
| 45 | + Expect(err).NotTo(Succeed()) |
| 46 | + Expect(isValid).NotTo(BeTrue()) |
| 47 | + }) |
| 48 | + }) |
| 49 | + |
| 50 | + }) |
| 51 | + |
40 | 52 | Describe("ValidateEvent", func() {
|
41 | 53 | Context("with nil event", func() {
|
42 | 54 | It("fails", func() {
|
@@ -140,94 +152,69 @@ var _ = Describe("Cast", func() {
|
140 | 152 | })
|
141 | 153 | })
|
142 | 154 |
|
143 |
| - Describe("Validate", func() { |
144 |
| - Context("with a nil cast", func() { |
145 |
| - It("fails", func() { |
146 |
| - isValid, err := cast.Validate(nil) |
147 |
| - |
148 |
| - Expect(err).NotTo(Succeed()) |
149 |
| - Expect(isValid).NotTo(BeTrue()) |
150 |
| - }) |
151 |
| - }) |
152 |
| - |
153 |
| - Context("with invalid header", func() { |
| 155 | + Describe("ValidateEventStream", func() { |
| 156 | + Context("with empty stream", func() { |
154 | 157 | var data = cast.Cast{
|
155 |
| - Header: cast.Header{ |
156 |
| - Version: 123, |
157 |
| - }, |
| 158 | + Header: validHeader, |
| 159 | + EventStream: []*cast.Event{}, |
158 | 160 | }
|
159 | 161 |
|
160 |
| - It("fails", func() { |
| 162 | + It("is valid", func() { |
161 | 163 | isValid, err := cast.Validate(&data)
|
162 | 164 |
|
163 |
| - Expect(err).NotTo(Succeed()) |
164 |
| - Expect(isValid).NotTo(BeTrue()) |
| 165 | + Expect(err).To(Succeed()) |
| 166 | + Expect(isValid).To(BeTrue()) |
165 | 167 | })
|
166 | 168 | })
|
167 | 169 |
|
168 |
| - Context("regarding events", func() { |
169 |
| - Context("having an empty list of them", func() { |
170 |
| - var data = cast.Cast{ |
171 |
| - Header: validHeader, |
172 |
| - EventStream: []*cast.Event{}, |
173 |
| - } |
174 |
| - |
175 |
| - It("is valid", func() { |
176 |
| - isValid, err := cast.Validate(&data) |
177 |
| - |
178 |
| - Expect(err).To(Succeed()) |
179 |
| - Expect(isValid).To(BeTrue()) |
180 |
| - }) |
181 |
| - }) |
182 |
| - |
183 |
| - It("fails if not sorted by time", func() { |
184 |
| - var data = cast.Cast{ |
185 |
| - Header: validHeader, |
186 |
| - EventStream: []*cast.Event{ |
187 |
| - &validEvent2, |
188 |
| - &validEvent1, |
189 |
| - &validEvent3, |
190 |
| - }, |
191 |
| - } |
| 170 | + It("fails if not sorted by time", func() { |
| 171 | + var data = cast.Cast{ |
| 172 | + Header: validHeader, |
| 173 | + EventStream: []*cast.Event{ |
| 174 | + &validEvent2, |
| 175 | + &validEvent1, |
| 176 | + &validEvent3, |
| 177 | + }, |
| 178 | + } |
192 | 179 |
|
193 |
| - isValid, err := cast.Validate(&data) |
| 180 | + isValid, err := cast.Validate(&data) |
194 | 181 |
|
195 |
| - Expect(err).NotTo(Succeed()) |
196 |
| - Expect(isValid).NotTo(BeTrue()) |
| 182 | + Expect(err).NotTo(Succeed()) |
| 183 | + Expect(isValid).NotTo(BeTrue()) |
197 | 184 |
|
198 |
| - }) |
| 185 | + }) |
199 | 186 |
|
200 |
| - It("succeeds if sorted and valid", func() { |
201 |
| - var data = cast.Cast{ |
202 |
| - Header: validHeader, |
203 |
| - EventStream: []*cast.Event{ |
204 |
| - &validEvent1, |
205 |
| - &validEvent2, |
206 |
| - &validEvent3, |
207 |
| - }, |
208 |
| - } |
| 187 | + It("succeeds if sorted and valid", func() { |
| 188 | + var data = cast.Cast{ |
| 189 | + Header: validHeader, |
| 190 | + EventStream: []*cast.Event{ |
| 191 | + &validEvent1, |
| 192 | + &validEvent2, |
| 193 | + &validEvent3, |
| 194 | + }, |
| 195 | + } |
209 | 196 |
|
210 |
| - isValid, err := cast.Validate(&data) |
| 197 | + isValid, err := cast.Validate(&data) |
211 | 198 |
|
212 |
| - Expect(err).To(Succeed()) |
213 |
| - Expect(isValid).To(BeTrue()) |
214 |
| - }) |
| 199 | + Expect(err).To(Succeed()) |
| 200 | + Expect(isValid).To(BeTrue()) |
| 201 | + }) |
215 | 202 |
|
216 |
| - It("fails if there's an invalid event", func() { |
217 |
| - var data = cast.Cast{ |
218 |
| - Header: validHeader, |
219 |
| - EventStream: []*cast.Event{ |
220 |
| - &validEvent1, |
221 |
| - &invalidEvent4, |
222 |
| - }, |
223 |
| - } |
| 203 | + It("fails if there's an invalid event", func() { |
| 204 | + var data = cast.Cast{ |
| 205 | + Header: validHeader, |
| 206 | + EventStream: []*cast.Event{ |
| 207 | + &validEvent1, |
| 208 | + &invalidEvent4, |
| 209 | + }, |
| 210 | + } |
224 | 211 |
|
225 |
| - isValid, err := cast.Validate(&data) |
| 212 | + isValid, err := cast.Validate(&data) |
226 | 213 |
|
227 |
| - Expect(err).NotTo(Succeed()) |
228 |
| - Expect(isValid).NotTo(BeTrue()) |
229 |
| - }) |
| 214 | + Expect(err).NotTo(Succeed()) |
| 215 | + Expect(isValid).NotTo(BeTrue()) |
230 | 216 | })
|
| 217 | + |
231 | 218 | })
|
232 | 219 |
|
233 | 220 | Describe("Encode", func() {
|
|
0 commit comments