OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // 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 454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
465 for i := 0; i < MaxIndexColumns+1; i++ { | 465 for i := 0; i < MaxIndexColumns+1; i++ { |
466 id.SortBy = append(id.SortBy, ds.IndexCo
lumn{Property: "Hi", Descending: true}) | 466 id.SortBy = append(id.SortBy, ds.IndexCo
lumn{Property: "Hi", Descending: true}) |
467 } | 467 } |
468 data := ToBytes(*id.PrepForIdxTable()) | 468 data := ToBytes(*id.PrepForIdxTable()) |
469 newID, err = ReadIndexDefinition(mkBuf(data)) | 469 newID, err = ReadIndexDefinition(mkBuf(data)) |
470 So(err, ShouldErrLike, "over 64 sort orders") | 470 So(err, ShouldErrLike, "over 64 sort orders") |
471 }) | 471 }) |
472 }) | 472 }) |
473 }) | 473 }) |
474 } | 474 } |
| 475 |
| 476 func TestPartialSerialization(t *testing.T) { |
| 477 t.Parallel() |
| 478 |
| 479 fakeKey := mkKey("dev~app", "ns", "parentKind", "sid", "knd", 10) |
| 480 |
| 481 Convey("TestPartialSerialization", t, func() { |
| 482 Convey("list", func() { |
| 483 pm := ds.PropertyMap{ |
| 484 "wat": {mpNI("thing"), mp("hat"), mp(100)}, |
| 485 "nerd": {mp(103.7)}, |
| 486 "spaz": {mpNI(false)}, |
| 487 } |
| 488 sip := PropertyMapPartially(fakeKey, pm) |
| 489 So(len(sip), ShouldEqual, 4) |
| 490 |
| 491 Convey("single collated", func() { |
| 492 Convey("indexableMap", func() { |
| 493 So(sip, ShouldResemble, SerializedPmap{ |
| 494 "wat": { |
| 495 ToBytes(mp("hat")), |
| 496 ToBytes(mp(100)), |
| 497 // 'thing' is skipped, b
ecause it's not NoIndex |
| 498 }, |
| 499 "nerd": { |
| 500 ToBytes(mp(103.7)), |
| 501 }, |
| 502 "__key__": { |
| 503 ToBytes(mp(fakeKey)), |
| 504 }, |
| 505 "__ancestor__": { |
| 506 ToBytes(mp(fakeKey)), |
| 507 ToBytes(mp(fakeKey.Paren
t())), |
| 508 }, |
| 509 }) |
| 510 }) |
| 511 }) |
| 512 }) |
| 513 }) |
| 514 } |
OLD | NEW |