Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: service/datastore/pls_test.go

Issue 1358743002: Make Get operations only serialize the bare minimum. (Closed) Base URL: https://github.com/luci/gae.git@fix_time
Patch Set: PropertyMap should always copy on save-out functions to avoid external mutation Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « service/datastore/pls_impl.go ('k') | service/datastore/properties.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 // adapted from github.com/golang/appengine/datastore 5 // adapted from github.com/golang/appengine/datastore
6 6
7 package datastore 7 package datastore
8 8
9 import ( 9 import (
10 "bytes" 10 "bytes"
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 So(props[i].SetValue(v+v, props[i].IndexSetting( )), ShouldBeNil) 368 So(props[i].SetValue(v+v, props[i].IndexSetting( )), ShouldBeNil)
369 case int64: 369 case int64:
370 // + means integer addition. 370 // + means integer addition.
371 So(props[i].SetValue(v+v, props[i].IndexSetting( )), ShouldBeNil) 371 So(props[i].SetValue(v+v, props[i].IndexSetting( )), ShouldBeNil)
372 } 372 }
373 } 373 }
374 } 374 }
375 return propMap, nil 375 return propMap, nil
376 } 376 }
377 377
378 func (d *Doubler) GetAllMeta() PropertyMap { retur n nil }
378 func (d *Doubler) GetMeta(string) (interface{}, error) { retur n nil, ErrMetaFieldUnset } 379 func (d *Doubler) GetMeta(string) (interface{}, error) { retur n nil, ErrMetaFieldUnset }
379 func (d *Doubler) GetMetaDefault(_ string, dflt interface{}) interface{} { retur n dflt } 380 func (d *Doubler) GetMetaDefault(_ string, dflt interface{}) interface{} { retur n dflt }
380 func (d *Doubler) SetMeta(string, interface{}) error { retur n ErrMetaFieldUnset } 381 func (d *Doubler) SetMeta(string, interface{}) error { retur n ErrMetaFieldUnset }
381 func (d *Doubler) Problem() error { retur n nil } 382 func (d *Doubler) Problem() error { retur n nil }
382 383
383 var _ PropertyLoadSaver = (*Doubler)(nil) 384 var _ PropertyLoadSaver = (*Doubler)(nil)
384 385
385 type Deriver struct { 386 type Deriver struct {
386 S, Derived, Ignored string 387 S, Derived, Ignored string
387 } 388 }
388 389
389 func (d *Deriver) Load(props PropertyMap) error { 390 func (d *Deriver) Load(props PropertyMap) error {
390 for name, p := range props { 391 for name, p := range props {
391 if name != "S" { 392 if name != "S" {
392 continue 393 continue
393 } 394 }
394 d.S = p[0].Value().(string) 395 d.S = p[0].Value().(string)
395 d.Derived = "derived+" + d.S 396 d.Derived = "derived+" + d.S
396 } 397 }
397 return nil 398 return nil
398 } 399 }
399 400
400 func (d *Deriver) Save(withMeta bool) (PropertyMap, error) { 401 func (d *Deriver) Save(withMeta bool) (PropertyMap, error) {
401 return map[string][]Property{ 402 return map[string][]Property{
402 "S": {mp(d.S)}, 403 "S": {mp(d.S)},
403 }, nil 404 }, nil
404 } 405 }
405 406
407 func (d *Deriver) GetAllMeta() PropertyMap { retur n nil }
406 func (d *Deriver) GetMeta(string) (interface{}, error) { retur n nil, ErrMetaFieldUnset } 408 func (d *Deriver) GetMeta(string) (interface{}, error) { retur n nil, ErrMetaFieldUnset }
407 func (d *Deriver) GetMetaDefault(_ string, dflt interface{}) interface{} { retur n dflt } 409 func (d *Deriver) GetMetaDefault(_ string, dflt interface{}) interface{} { retur n dflt }
408 func (d *Deriver) SetMeta(string, interface{}) error { retur n ErrMetaFieldUnset } 410 func (d *Deriver) SetMeta(string, interface{}) error { retur n ErrMetaFieldUnset }
409 func (d *Deriver) Problem() error { retur n nil } 411 func (d *Deriver) Problem() error { retur n nil }
410 412
411 var _ PropertyLoadSaver = (*Deriver)(nil) 413 var _ PropertyLoadSaver = (*Deriver)(nil)
412 414
413 type BK struct { 415 type BK struct {
414 Key blobstore.Key 416 Key blobstore.Key
415 } 417 }
(...skipping 1295 matching lines...) Expand 10 before | Expand all | Expand 10 after
1711 1713
1712 Convey("Bad default meta type", func() { 1714 Convey("Bad default meta type", func() {
1713 type BadDefault struct { 1715 type BadDefault struct {
1714 Val time.Time `gae:"$meta,tomorrow"` 1716 Val time.Time `gae:"$meta,tomorrow"`
1715 } 1717 }
1716 pls := GetPLS(&BadDefault{}) 1718 pls := GetPLS(&BadDefault{})
1717 So(pls.Problem().Error(), ShouldContainSubstring, "bad t ype") 1719 So(pls.Problem().Error(), ShouldContainSubstring, "bad t ype")
1718 }) 1720 })
1719 }) 1721 })
1720 } 1722 }
OLDNEW
« no previous file with comments | « service/datastore/pls_impl.go ('k') | service/datastore/properties.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698