| OLD | NEW |
| 1 // Copyright 2015 The LUCI Authors. All rights reserved. | 1 // Copyright 2015 The LUCI Authors. All rights reserved. |
| 2 // Use of this source code is governed under the Apache License, Version 2.0 | 2 // Use of this source code is governed under the Apache License, Version 2.0 |
| 3 // that can be found in the LICENSE file. | 3 // that can be found in the LICENSE file. |
| 4 | 4 |
| 5 package serialize | 5 package serialize |
| 6 | 6 |
| 7 import ( | 7 import ( |
| 8 "bytes" | 8 "bytes" |
| 9 "fmt" | 9 "fmt" |
| 10 "io" | 10 "io" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 mp = ds.MkProperty | 27 mp = ds.MkProperty |
| 28 mpNI = ds.MkPropertyNI | 28 mpNI = ds.MkPropertyNI |
| 29 ) | 29 ) |
| 30 | 30 |
| 31 type dspmapTC struct { | 31 type dspmapTC struct { |
| 32 name string | 32 name string |
| 33 props ds.PropertyMap | 33 props ds.PropertyMap |
| 34 } | 34 } |
| 35 | 35 |
| 36 func mkKey(appID, namespace string, elems ...interface{}) *ds.Key { | 36 func mkKey(appID, namespace string, elems ...interface{}) *ds.Key { |
| 37 » return ds.KeyContext{appID, namespace}.MakeKey(elems...) | 37 » return ds.MkKeyContext(appID, namespace).MakeKey(elems...) |
| 38 } | 38 } |
| 39 | 39 |
| 40 func mkBuf(data []byte) Buffer { | 40 func mkBuf(data []byte) Buffer { |
| 41 return Invertible(bytes.NewBuffer(data)) | 41 return Invertible(bytes.NewBuffer(data)) |
| 42 } | 42 } |
| 43 | 43 |
| 44 // TODO(riannucci): dedup with datastore/key testing file | 44 // TODO(riannucci): dedup with datastore/key testing file |
| 45 func ShouldEqualKey(actual interface{}, expected ...interface{}) string { | 45 func ShouldEqualKey(actual interface{}, expected ...interface{}) string { |
| 46 if len(expected) != 1 { | 46 if len(expected) != 1 { |
| 47 return fmt.Sprintf("Assertion requires 1 expected value, got %d"
, len(expected)) | 47 return fmt.Sprintf("Assertion requires 1 expected value, got %d"
, len(expected)) |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 }, | 107 }, |
| 108 }, | 108 }, |
| 109 } | 109 } |
| 110 | 110 |
| 111 Convey("PropertyMap serialization", t, func() { | 111 Convey("PropertyMap serialization", t, func() { |
| 112 Convey("round trip", func() { | 112 Convey("round trip", func() { |
| 113 for _, tc := range tests { | 113 for _, tc := range tests { |
| 114 tc := tc | 114 tc := tc |
| 115 Convey(tc.name, func() { | 115 Convey(tc.name, func() { |
| 116 data := ToBytesWithContext(tc.props) | 116 data := ToBytesWithContext(tc.props) |
| 117 » » » » » dec, err := ReadPropertyMap(mkBuf(data),
WithContext, ds.KeyContext{}) | 117 » » » » » dec, err := ReadPropertyMap(mkBuf(data),
WithContext, ds.MkKeyContext("", "")) |
| 118 So(err, ShouldBeNil) | 118 So(err, ShouldBeNil) |
| 119 So(dec, ShouldResemble, tc.props) | 119 So(dec, ShouldResemble, tc.props) |
| 120 }) | 120 }) |
| 121 } | 121 } |
| 122 }) | 122 }) |
| 123 }) | 123 }) |
| 124 } | 124 } |
| 125 | 125 |
| 126 func die(err error) { | 126 func die(err error) { |
| 127 if err != nil { | 127 if err != nil { |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 t, err := ReadTime(mkBuf(buf.Bytes())) | 200 t, err := ReadTime(mkBuf(buf.Bytes())) |
| 201 So(err, ShouldBeNil) | 201 So(err, ShouldBeNil) |
| 202 So(t.Equal(time.Time{}), ShouldBeTrue) | 202 So(t.Equal(time.Time{}), ShouldBeTrue) |
| 203 }) | 203 }) |
| 204 | 204 |
| 205 Convey("ReadKey", func() { | 205 Convey("ReadKey", func() { |
| 206 Convey("good cases", func() { | 206 Convey("good cases", func() { |
| 207 Convey("w/ ctx decodes normally w/ ctx", func()
{ | 207 Convey("w/ ctx decodes normally w/ ctx", func()
{ |
| 208 k := mkKey("aid", "ns", "knd", "yo", "ot
her", 10) | 208 k := mkKey("aid", "ns", "knd", "yo", "ot
her", 10) |
| 209 data := ToBytesWithContext(k) | 209 data := ToBytesWithContext(k) |
| 210 » » » » » dk, err := ReadKey(mkBuf(data), WithCont
ext, ds.KeyContext{}) | 210 » » » » » dk, err := ReadKey(mkBuf(data), WithCont
ext, ds.MkKeyContext("", "")) |
| 211 So(err, ShouldBeNil) | 211 So(err, ShouldBeNil) |
| 212 So(dk, ShouldEqualKey, k) | 212 So(dk, ShouldEqualKey, k) |
| 213 }) | 213 }) |
| 214 Convey("w/ ctx decodes normally w/o ctx", func()
{ | 214 Convey("w/ ctx decodes normally w/o ctx", func()
{ |
| 215 k := mkKey("aid", "ns", "knd", "yo", "ot
her", 10) | 215 k := mkKey("aid", "ns", "knd", "yo", "ot
her", 10) |
| 216 data := ToBytesWithContext(k) | 216 data := ToBytesWithContext(k) |
| 217 » » » » » dk, err := ReadKey(mkBuf(data), WithoutC
ontext, ds.KeyContext{"spam", "nerd"}) | 217 » » » » » dk, err := ReadKey(mkBuf(data), WithoutC
ontext, ds.MkKeyContext("spam", "nerd")) |
| 218 So(err, ShouldBeNil) | 218 So(err, ShouldBeNil) |
| 219 So(dk, ShouldEqualKey, mkKey("spam", "ne
rd", "knd", "yo", "other", 10)) | 219 So(dk, ShouldEqualKey, mkKey("spam", "ne
rd", "knd", "yo", "other", 10)) |
| 220 }) | 220 }) |
| 221 Convey("w/o ctx decodes normally w/ ctx", func()
{ | 221 Convey("w/o ctx decodes normally w/ ctx", func()
{ |
| 222 k := mkKey("aid", "ns", "knd", "yo", "ot
her", 10) | 222 k := mkKey("aid", "ns", "knd", "yo", "ot
her", 10) |
| 223 data := ToBytes(k) | 223 data := ToBytes(k) |
| 224 » » » » » dk, err := ReadKey(mkBuf(data), WithCont
ext, ds.KeyContext{"spam", "nerd"}) | 224 » » » » » dk, err := ReadKey(mkBuf(data), WithCont
ext, ds.MkKeyContext("spam", "nerd")) |
| 225 So(err, ShouldBeNil) | 225 So(err, ShouldBeNil) |
| 226 So(dk, ShouldEqualKey, mkKey("", "", "kn
d", "yo", "other", 10)) | 226 So(dk, ShouldEqualKey, mkKey("", "", "kn
d", "yo", "other", 10)) |
| 227 }) | 227 }) |
| 228 Convey("w/o ctx decodes normally w/o ctx", func(
) { | 228 Convey("w/o ctx decodes normally w/o ctx", func(
) { |
| 229 k := mkKey("aid", "ns", "knd", "yo", "ot
her", 10) | 229 k := mkKey("aid", "ns", "knd", "yo", "ot
her", 10) |
| 230 data := ToBytes(k) | 230 data := ToBytes(k) |
| 231 » » » » » dk, err := ReadKey(mkBuf(data), WithoutC
ontext, ds.KeyContext{"spam", "nerd"}) | 231 » » » » » dk, err := ReadKey(mkBuf(data), WithoutC
ontext, ds.MkKeyContext("spam", "nerd")) |
| 232 So(err, ShouldBeNil) | 232 So(err, ShouldBeNil) |
| 233 So(dk, ShouldEqualKey, mkKey("spam", "ne
rd", "knd", "yo", "other", 10)) | 233 So(dk, ShouldEqualKey, mkKey("spam", "ne
rd", "knd", "yo", "other", 10)) |
| 234 }) | 234 }) |
| 235 Convey("IntIDs always sort before StringIDs", fu
nc() { | 235 Convey("IntIDs always sort before StringIDs", fu
nc() { |
| 236 // -1 writes as almost all 1's in the fi
rst byte under cmpbin, even | 236 // -1 writes as almost all 1's in the fi
rst byte under cmpbin, even |
| 237 // though it's technically not a valid k
ey. | 237 // though it's technically not a valid k
ey. |
| 238 k := mkKey("aid", "ns", "knd", -1) | 238 k := mkKey("aid", "ns", "knd", -1) |
| 239 data := ToBytes(k) | 239 data := ToBytes(k) |
| 240 | 240 |
| 241 k = mkKey("aid", "ns", "knd", "hat") | 241 k = mkKey("aid", "ns", "knd", "hat") |
| 242 data2 := ToBytes(k) | 242 data2 := ToBytes(k) |
| 243 | 243 |
| 244 So(string(data), ShouldBeLessThan, strin
g(data2)) | 244 So(string(data), ShouldBeLessThan, strin
g(data2)) |
| 245 }) | 245 }) |
| 246 }) | 246 }) |
| 247 | 247 |
| 248 Convey("err cases", func() { | 248 Convey("err cases", func() { |
| 249 buf := mkBuf(nil) | 249 buf := mkBuf(nil) |
| 250 Convey("nil", func() { | 250 Convey("nil", func() { |
| 251 » » » » » _, err := ReadKey(buf, WithContext, ds.K
eyContext{}) | 251 » » » » » _, err := ReadKey(buf, WithContext, ds.M
kKeyContext("", "")) |
| 252 So(err, ShouldEqual, io.EOF) | 252 So(err, ShouldEqual, io.EOF) |
| 253 }) | 253 }) |
| 254 Convey("str", func() { | 254 Convey("str", func() { |
| 255 _, err := buf.WriteString("sup") | 255 _, err := buf.WriteString("sup") |
| 256 die(err) | 256 die(err) |
| 257 » » » » » _, err = ReadKey(buf, WithContext, ds.Ke
yContext{}) | 257 » » » » » _, err = ReadKey(buf, WithContext, ds.Mk
KeyContext("", "")) |
| 258 So(err, ShouldErrLike, "expected actualC
tx") | 258 So(err, ShouldErrLike, "expected actualC
tx") |
| 259 }) | 259 }) |
| 260 Convey("truncated 1", func() { | 260 Convey("truncated 1", func() { |
| 261 die(buf.WriteByte(1)) // actualCtx == 1 | 261 die(buf.WriteByte(1)) // actualCtx == 1 |
| 262 » » » » » _, err := ReadKey(buf, WithContext, ds.K
eyContext{}) | 262 » » » » » _, err := ReadKey(buf, WithContext, ds.M
kKeyContext("", "")) |
| 263 So(err, ShouldEqual, io.EOF) | 263 So(err, ShouldEqual, io.EOF) |
| 264 }) | 264 }) |
| 265 Convey("truncated 2", func() { | 265 Convey("truncated 2", func() { |
| 266 die(buf.WriteByte(1)) // actualCtx == 1 | 266 die(buf.WriteByte(1)) // actualCtx == 1 |
| 267 ws(buf, "aid") | 267 ws(buf, "aid") |
| 268 » » » » » _, err := ReadKey(buf, WithContext, ds.K
eyContext{}) | 268 » » » » » _, err := ReadKey(buf, WithContext, ds.M
kKeyContext("", "")) |
| 269 So(err, ShouldEqual, io.EOF) | 269 So(err, ShouldEqual, io.EOF) |
| 270 }) | 270 }) |
| 271 Convey("truncated 3", func() { | 271 Convey("truncated 3", func() { |
| 272 die(buf.WriteByte(1)) // actualCtx == 1 | 272 die(buf.WriteByte(1)) // actualCtx == 1 |
| 273 ws(buf, "aid") | 273 ws(buf, "aid") |
| 274 ws(buf, "ns") | 274 ws(buf, "ns") |
| 275 » » » » » _, err := ReadKey(buf, WithContext, ds.K
eyContext{}) | 275 » » » » » _, err := ReadKey(buf, WithContext, ds.M
kKeyContext("", "")) |
| 276 So(err, ShouldEqual, io.EOF) | 276 So(err, ShouldEqual, io.EOF) |
| 277 }) | 277 }) |
| 278 Convey("huge key", func() { | 278 Convey("huge key", func() { |
| 279 die(buf.WriteByte(1)) // actualCtx == 1 | 279 die(buf.WriteByte(1)) // actualCtx == 1 |
| 280 ws(buf, "aid") | 280 ws(buf, "aid") |
| 281 ws(buf, "ns") | 281 ws(buf, "ns") |
| 282 for i := 1; i < 60; i++ { | 282 for i := 1; i < 60; i++ { |
| 283 die(buf.WriteByte(1)) | 283 die(buf.WriteByte(1)) |
| 284 die(WriteKeyTok(buf, ds.KeyTok{K
ind: "sup", IntID: int64(i)})) | 284 die(WriteKeyTok(buf, ds.KeyTok{K
ind: "sup", IntID: int64(i)})) |
| 285 } | 285 } |
| 286 die(buf.WriteByte(0)) | 286 die(buf.WriteByte(0)) |
| 287 » » » » » _, err := ReadKey(buf, WithContext, ds.K
eyContext{}) | 287 » » » » » _, err := ReadKey(buf, WithContext, ds.M
kKeyContext("", "")) |
| 288 So(err, ShouldErrLike, "huge key") | 288 So(err, ShouldErrLike, "huge key") |
| 289 }) | 289 }) |
| 290 Convey("insufficient tokens", func() { | 290 Convey("insufficient tokens", func() { |
| 291 die(buf.WriteByte(1)) // actualCtx == 1 | 291 die(buf.WriteByte(1)) // actualCtx == 1 |
| 292 ws(buf, "aid") | 292 ws(buf, "aid") |
| 293 ws(buf, "ns") | 293 ws(buf, "ns") |
| 294 wui(buf, 2) | 294 wui(buf, 2) |
| 295 » » » » » _, err := ReadKey(buf, WithContext, ds.K
eyContext{}) | 295 » » » » » _, err := ReadKey(buf, WithContext, ds.M
kKeyContext("", "")) |
| 296 So(err, ShouldEqual, io.EOF) | 296 So(err, ShouldEqual, io.EOF) |
| 297 }) | 297 }) |
| 298 Convey("partial token 1", func() { | 298 Convey("partial token 1", func() { |
| 299 die(buf.WriteByte(1)) // actualCtx == 1 | 299 die(buf.WriteByte(1)) // actualCtx == 1 |
| 300 ws(buf, "aid") | 300 ws(buf, "aid") |
| 301 ws(buf, "ns") | 301 ws(buf, "ns") |
| 302 die(buf.WriteByte(1)) | 302 die(buf.WriteByte(1)) |
| 303 ws(buf, "hi") | 303 ws(buf, "hi") |
| 304 » » » » » _, err := ReadKey(buf, WithContext, ds.K
eyContext{}) | 304 » » » » » _, err := ReadKey(buf, WithContext, ds.M
kKeyContext("", "")) |
| 305 So(err, ShouldEqual, io.EOF) | 305 So(err, ShouldEqual, io.EOF) |
| 306 }) | 306 }) |
| 307 Convey("partial token 2", func() { | 307 Convey("partial token 2", func() { |
| 308 die(buf.WriteByte(1)) // actualCtx == 1 | 308 die(buf.WriteByte(1)) // actualCtx == 1 |
| 309 ws(buf, "aid") | 309 ws(buf, "aid") |
| 310 ws(buf, "ns") | 310 ws(buf, "ns") |
| 311 die(buf.WriteByte(1)) | 311 die(buf.WriteByte(1)) |
| 312 ws(buf, "hi") | 312 ws(buf, "hi") |
| 313 die(buf.WriteByte(byte(ds.PTString))) | 313 die(buf.WriteByte(byte(ds.PTString))) |
| 314 » » » » » _, err := ReadKey(buf, WithContext, ds.K
eyContext{}) | 314 » » » » » _, err := ReadKey(buf, WithContext, ds.M
kKeyContext("", "")) |
| 315 So(err, ShouldEqual, io.EOF) | 315 So(err, ShouldEqual, io.EOF) |
| 316 }) | 316 }) |
| 317 Convey("bad token (invalid type)", func() { | 317 Convey("bad token (invalid type)", func() { |
| 318 die(buf.WriteByte(1)) // actualCtx == 1 | 318 die(buf.WriteByte(1)) // actualCtx == 1 |
| 319 ws(buf, "aid") | 319 ws(buf, "aid") |
| 320 ws(buf, "ns") | 320 ws(buf, "ns") |
| 321 die(buf.WriteByte(1)) | 321 die(buf.WriteByte(1)) |
| 322 ws(buf, "hi") | 322 ws(buf, "hi") |
| 323 die(buf.WriteByte(byte(ds.PTBlobKey))) | 323 die(buf.WriteByte(byte(ds.PTBlobKey))) |
| 324 » » » » » _, err := ReadKey(buf, WithContext, ds.K
eyContext{}) | 324 » » » » » _, err := ReadKey(buf, WithContext, ds.M
kKeyContext("", "")) |
| 325 So(err, ShouldErrLike, "invalid type PTB
lobKey") | 325 So(err, ShouldErrLike, "invalid type PTB
lobKey") |
| 326 }) | 326 }) |
| 327 Convey("bad token (invalid IntID)", func() { | 327 Convey("bad token (invalid IntID)", func() { |
| 328 die(buf.WriteByte(1)) // actualCtx == 1 | 328 die(buf.WriteByte(1)) // actualCtx == 1 |
| 329 ws(buf, "aid") | 329 ws(buf, "aid") |
| 330 ws(buf, "ns") | 330 ws(buf, "ns") |
| 331 die(buf.WriteByte(1)) | 331 die(buf.WriteByte(1)) |
| 332 ws(buf, "hi") | 332 ws(buf, "hi") |
| 333 die(buf.WriteByte(byte(ds.PTInt))) | 333 die(buf.WriteByte(byte(ds.PTInt))) |
| 334 wi(buf, -2) | 334 wi(buf, -2) |
| 335 » » » » » _, err := ReadKey(buf, WithContext, ds.K
eyContext{}) | 335 » » » » » _, err := ReadKey(buf, WithContext, ds.M
kKeyContext("", "")) |
| 336 So(err, ShouldErrLike, "zero/negative") | 336 So(err, ShouldErrLike, "zero/negative") |
| 337 }) | 337 }) |
| 338 }) | 338 }) |
| 339 }) | 339 }) |
| 340 | 340 |
| 341 Convey("ReadGeoPoint", func() { | 341 Convey("ReadGeoPoint", func() { |
| 342 buf := mkBuf(nil) | 342 buf := mkBuf(nil) |
| 343 Convey("trunc 1", func() { | 343 Convey("trunc 1", func() { |
| 344 _, err := ReadGeoPoint(buf) | 344 _, err := ReadGeoPoint(buf) |
| 345 So(err, ShouldEqual, io.EOF) | 345 So(err, ShouldEqual, io.EOF) |
| (...skipping 24 matching lines...) Expand all Loading... |
| 370 Convey("ReadTime", func() { | 370 Convey("ReadTime", func() { |
| 371 Convey("trunc 1", func() { | 371 Convey("trunc 1", func() { |
| 372 _, err := ReadTime(mkBuf(nil)) | 372 _, err := ReadTime(mkBuf(nil)) |
| 373 So(err, ShouldEqual, io.EOF) | 373 So(err, ShouldEqual, io.EOF) |
| 374 }) | 374 }) |
| 375 }) | 375 }) |
| 376 | 376 |
| 377 Convey("ReadProperty", func() { | 377 Convey("ReadProperty", func() { |
| 378 buf := mkBuf(nil) | 378 buf := mkBuf(nil) |
| 379 Convey("trunc 1", func() { | 379 Convey("trunc 1", func() { |
| 380 » » » » p, err := ReadProperty(buf, WithContext, ds.KeyC
ontext{}) | 380 » » » » p, err := ReadProperty(buf, WithContext, ds.MkKe
yContext("", "")) |
| 381 So(err, ShouldEqual, io.EOF) | 381 So(err, ShouldEqual, io.EOF) |
| 382 So(p.Type(), ShouldEqual, ds.PTNull) | 382 So(p.Type(), ShouldEqual, ds.PTNull) |
| 383 So(p.Value(), ShouldBeNil) | 383 So(p.Value(), ShouldBeNil) |
| 384 }) | 384 }) |
| 385 Convey("trunc (PTBytes)", func() { | 385 Convey("trunc (PTBytes)", func() { |
| 386 die(buf.WriteByte(byte(ds.PTBytes))) | 386 die(buf.WriteByte(byte(ds.PTBytes))) |
| 387 » » » » _, err := ReadProperty(buf, WithContext, ds.KeyC
ontext{}) | 387 » » » » _, err := ReadProperty(buf, WithContext, ds.MkKe
yContext("", "")) |
| 388 So(err, ShouldEqual, io.EOF) | 388 So(err, ShouldEqual, io.EOF) |
| 389 }) | 389 }) |
| 390 Convey("trunc (PTBlobKey)", func() { | 390 Convey("trunc (PTBlobKey)", func() { |
| 391 die(buf.WriteByte(byte(ds.PTBlobKey))) | 391 die(buf.WriteByte(byte(ds.PTBlobKey))) |
| 392 » » » » _, err := ReadProperty(buf, WithContext, ds.KeyC
ontext{}) | 392 » » » » _, err := ReadProperty(buf, WithContext, ds.MkKe
yContext("", "")) |
| 393 So(err, ShouldEqual, io.EOF) | 393 So(err, ShouldEqual, io.EOF) |
| 394 }) | 394 }) |
| 395 Convey("invalid type", func() { | 395 Convey("invalid type", func() { |
| 396 die(buf.WriteByte(byte(ds.PTUnknown + 1))) | 396 die(buf.WriteByte(byte(ds.PTUnknown + 1))) |
| 397 » » » » _, err := ReadProperty(buf, WithContext, ds.KeyC
ontext{}) | 397 » » » » _, err := ReadProperty(buf, WithContext, ds.MkKe
yContext("", "")) |
| 398 So(err, ShouldErrLike, "unknown type!") | 398 So(err, ShouldErrLike, "unknown type!") |
| 399 }) | 399 }) |
| 400 }) | 400 }) |
| 401 | 401 |
| 402 Convey("ReadPropertyMap", func() { | 402 Convey("ReadPropertyMap", func() { |
| 403 buf := mkBuf(nil) | 403 buf := mkBuf(nil) |
| 404 Convey("trunc 1", func() { | 404 Convey("trunc 1", func() { |
| 405 » » » » _, err := ReadPropertyMap(buf, WithContext, ds.K
eyContext{}) | 405 » » » » _, err := ReadPropertyMap(buf, WithContext, ds.M
kKeyContext("", "")) |
| 406 So(err, ShouldEqual, io.EOF) | 406 So(err, ShouldEqual, io.EOF) |
| 407 }) | 407 }) |
| 408 Convey("too many rows", func() { | 408 Convey("too many rows", func() { |
| 409 wui(buf, 1000000) | 409 wui(buf, 1000000) |
| 410 » » » » _, err := ReadPropertyMap(buf, WithContext, ds.K
eyContext{}) | 410 » » » » _, err := ReadPropertyMap(buf, WithContext, ds.M
kKeyContext("", "")) |
| 411 So(err, ShouldErrLike, "huge number of rows") | 411 So(err, ShouldErrLike, "huge number of rows") |
| 412 }) | 412 }) |
| 413 Convey("trunc 2", func() { | 413 Convey("trunc 2", func() { |
| 414 wui(buf, 10) | 414 wui(buf, 10) |
| 415 » » » » _, err := ReadPropertyMap(buf, WithContext, ds.K
eyContext{}) | 415 » » » » _, err := ReadPropertyMap(buf, WithContext, ds.M
kKeyContext("", "")) |
| 416 So(err, ShouldEqual, io.EOF) | 416 So(err, ShouldEqual, io.EOF) |
| 417 }) | 417 }) |
| 418 Convey("trunc 3", func() { | 418 Convey("trunc 3", func() { |
| 419 wui(buf, 10) | 419 wui(buf, 10) |
| 420 ws(buf, "ohai") | 420 ws(buf, "ohai") |
| 421 » » » » _, err := ReadPropertyMap(buf, WithContext, ds.K
eyContext{}) | 421 » » » » _, err := ReadPropertyMap(buf, WithContext, ds.M
kKeyContext("", "")) |
| 422 So(err, ShouldEqual, io.EOF) | 422 So(err, ShouldEqual, io.EOF) |
| 423 }) | 423 }) |
| 424 Convey("too many values", func() { | 424 Convey("too many values", func() { |
| 425 wui(buf, 10) | 425 wui(buf, 10) |
| 426 ws(buf, "ohai") | 426 ws(buf, "ohai") |
| 427 wui(buf, 100000) | 427 wui(buf, 100000) |
| 428 » » » » _, err := ReadPropertyMap(buf, WithContext, ds.K
eyContext{}) | 428 » » » » _, err := ReadPropertyMap(buf, WithContext, ds.M
kKeyContext("", "")) |
| 429 So(err, ShouldErrLike, "huge number of propertie
s") | 429 So(err, ShouldErrLike, "huge number of propertie
s") |
| 430 }) | 430 }) |
| 431 Convey("trunc 4", func() { | 431 Convey("trunc 4", func() { |
| 432 wui(buf, 10) | 432 wui(buf, 10) |
| 433 ws(buf, "ohai") | 433 ws(buf, "ohai") |
| 434 wui(buf, 10) | 434 wui(buf, 10) |
| 435 » » » » _, err := ReadPropertyMap(buf, WithContext, ds.K
eyContext{}) | 435 » » » » _, err := ReadPropertyMap(buf, WithContext, ds.M
kKeyContext("", "")) |
| 436 So(err, ShouldEqual, io.EOF) | 436 So(err, ShouldEqual, io.EOF) |
| 437 }) | 437 }) |
| 438 }) | 438 }) |
| 439 | 439 |
| 440 Convey("IndexDefinition", func() { | 440 Convey("IndexDefinition", func() { |
| 441 id := ds.IndexDefinition{Kind: "kind"} | 441 id := ds.IndexDefinition{Kind: "kind"} |
| 442 data := ToBytes(*id.PrepForIdxTable()) | 442 data := ToBytes(*id.PrepForIdxTable()) |
| 443 newID, err := ReadIndexDefinition(mkBuf(data)) | 443 newID, err := ReadIndexDefinition(mkBuf(data)) |
| 444 So(err, ShouldBeNil) | 444 So(err, ShouldBeNil) |
| 445 So(newID.Flip(), ShouldResemble, id.Normalize()) | 445 So(newID.Flip(), ShouldResemble, id.Normalize()) |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 509 "__ancestor__": { | 509 "__ancestor__": { |
| 510 ToBytes(mp(fakeKey)), | 510 ToBytes(mp(fakeKey)), |
| 511 ToBytes(mp(fakeKey.Paren
t())), | 511 ToBytes(mp(fakeKey.Paren
t())), |
| 512 }, | 512 }, |
| 513 }) | 513 }) |
| 514 }) | 514 }) |
| 515 }) | 515 }) |
| 516 }) | 516 }) |
| 517 }) | 517 }) |
| 518 } | 518 } |
| OLD | NEW |