Chromium Code Reviews| 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 memory | 5 package memory |
| 6 | 6 |
| 7 import ( | 7 import ( |
| 8 "fmt" | 8 "fmt" |
| 9 "strings" | 9 "strings" |
| 10 "testing" | 10 "testing" |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 78 "Extra", "hello", "waffle", | 78 "Extra", "hello", "waffle", |
| 79 ), | 79 ), |
| 80 pmap("$key", key("Kind", 3, "Kind", 2), Next, | 80 pmap("$key", key("Kind", 3, "Kind", 2), Next, |
| 81 "Val", 3, 4, Next, | 81 "Val", 3, 4, Next, |
| 82 "Extra", "hello", "waffle", | 82 "Extra", "hello", "waffle", |
| 83 ), | 83 ), |
| 84 pmap("$key", key("Kind", 3, "Kind", 3), Next, | 84 pmap("$key", key("Kind", 3, "Kind", 3), Next, |
| 85 "Val", 3, 4, 2, 1, Next, | 85 "Val", 3, 4, 2, 1, Next, |
| 86 "Extra", "nuts", | 86 "Extra", "nuts", |
| 87 ), | 87 ), |
| 88 » pmap("$key", ds.MakeKey("dev~app", "", "Kind", "id")), | 88 » pmap("$key", ds.MakeKey("dev~app", "jim", "Kind", "id")), |
|
iannucci
2016/04/22 19:13:49
s/jim/kat
| |
| 89 pmap("$key", ds.MakeKey("dev~app", "bob", "Kind", "id")), | 89 pmap("$key", ds.MakeKey("dev~app", "bob", "Kind", "id")), |
| 90 } | 90 } |
| 91 | 91 |
| 92 var collapsedData = []ds.PropertyMap{ | 92 var collapsedData = []ds.PropertyMap{ |
| 93 // PTTime | 93 // PTTime |
| 94 pmap("$key", key("Kind", 1), Next, | 94 pmap("$key", key("Kind", 1), Next, |
| 95 "Date", time.Date(2000, time.January, 1, 1, 1, 1, 1, time.UTC), Next, | 95 "Date", time.Date(2000, time.January, 1, 1, 1, 1, 1, time.UTC), Next, |
| 96 ), | 96 ), |
| 97 pmap("$key", key("Kind", 2), Next, | 97 pmap("$key", key("Kind", 2), Next, |
| 98 "Date", time.Date(2000, time.March, 1, 1, 1, 1, 1, time.UTC), Ne xt, | 98 "Date", time.Date(2000, time.March, 1, 1, 1, 1, 1, time.UTC), Ne xt, |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 344 "When", 996688461000000), | 344 "When", 996688461000000), |
| 345 }}, | 345 }}, |
| 346 | 346 |
| 347 // Original (complex) types are retained when ge tting the full value. | 347 // Original (complex) types are retained when ge tting the full value. |
| 348 {q: nq("Kind").Order("When"), get: []ds.Property Map{ | 348 {q: nq("Kind").Order("When"), get: []ds.Property Map{ |
| 349 stage1Data[1], | 349 stage1Data[1], |
| 350 stage1Data[3], | 350 stage1Data[3], |
| 351 stage1Data[2], | 351 stage1Data[2], |
| 352 }}, | 352 }}, |
| 353 {q: nq("__namespace__"), get: []ds.PropertyMap{ | 353 {q: nq("__namespace__"), get: []ds.PropertyMap{ |
| 354 pmap("$key", ds.MakeKey("dev~app", "", " __namespace__", 1)), | |
| 355 pmap("$key", ds.MakeKey("dev~app", "", " __namespace__", "bob")), | 354 pmap("$key", ds.MakeKey("dev~app", "", " __namespace__", "bob")), |
|
iannucci
2016/04/22 19:13:49
lost test for default namespace :/. Could we add a
| |
| 355 pmap("$key", ds.MakeKey("dev~app", "", " __namespace__", "jim")), | |
| 356 pmap("$key", ds.MakeKey("dev~app", "", " __namespace__", "ns")), | 356 pmap("$key", ds.MakeKey("dev~app", "", " __namespace__", "ns")), |
| 357 }}, | 357 }}, |
| 358 {q: nq("__namespace__").Offset(1), get: []ds.Pro pertyMap{ | 358 {q: nq("__namespace__").Offset(1), get: []ds.Pro pertyMap{ |
| 359 » » » » » pmap("$key", ds.MakeKey("dev~app", "", " __namespace__", "bob")), | 359 » » » » » pmap("$key", ds.MakeKey("dev~app", "", " __namespace__", "jim")), |
| 360 pmap("$key", ds.MakeKey("dev~app", "", " __namespace__", "ns")), | 360 pmap("$key", ds.MakeKey("dev~app", "", " __namespace__", "ns")), |
| 361 }}, | 361 }}, |
| 362 {q: nq("__namespace__").Offset(1).Limit(1), get: []ds.PropertyMap{ | 362 {q: nq("__namespace__").Offset(1).Limit(1), get: []ds.PropertyMap{ |
| 363 » » » » » pmap("$key", ds.MakeKey("dev~app", "", " __namespace__", "bob")), | 363 » » » » » pmap("$key", ds.MakeKey("dev~app", "", " __namespace__", "jim")), |
| 364 }}, | 364 }}, |
| 365 }, | 365 }, |
| 366 | 366 |
| 367 extraFns: []func(context.Context){ | 367 extraFns: []func(context.Context){ |
| 368 func(c context.Context) { | 368 func(c context.Context) { |
| 369 data := ds.Get(c) | 369 data := ds.Get(c) |
| 370 curs := ds.Cursor(nil) | 370 curs := ds.Cursor(nil) |
| 371 | 371 |
| 372 q := nq("").Gt("__key__", key("Kind", 2) ) | 372 q := nq("").Gt("__key__", key("Kind", 2) ) |
| 373 | 373 |
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 637 | 637 |
| 638 v, ok := actual.(error) | 638 v, ok := actual.(error) |
| 639 if !ok { | 639 if !ok { |
| 640 return fmt.Sprintf("type of 'actual' must be error, not %T", act ual) | 640 return fmt.Sprintf("type of 'actual' must be error, not %T", act ual) |
| 641 } | 641 } |
| 642 if v == nil || v == ds.Stop { | 642 if v == nil || v == ds.Stop { |
| 643 return "" | 643 return "" |
| 644 } | 644 } |
| 645 return fmt.Sprintf("expected success value, not %v", v) | 645 return fmt.Sprintf("expected success value, not %v", v) |
| 646 } | 646 } |
| OLD | NEW |