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

Side by Side Diff: filter/dscache/dscache_test.go

Issue 1355783002: Refactor keys and queries in datastore service and implementation. (Closed) Base URL: https://github.com/luci/gae.git@master
Patch Set: 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
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 package dscache 5 package dscache
6 6
7 import ( 7 import (
8 "bytes" 8 "bytes"
9 "encoding/binary" 9 "encoding/binary"
10 "errors" 10 "errors"
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 59
60 Convey("Test dscache", t, func() { 60 Convey("Test dscache", t, func() {
61 c := mathrand.Set(context.Background(), rand.New(rand.NewSource( 1))) 61 c := mathrand.Set(context.Background(), rand.New(rand.NewSource( 1)))
62 clk := testclock.New(zeroTime) 62 clk := testclock.New(zeroTime)
63 c = clock.Set(c, clk) 63 c = clock.Set(c, clk)
64 c = memory.Use(c) 64 c = memory.Use(c)
65 65
66 dsUnder := datastore.Get(c) 66 dsUnder := datastore.Get(c)
67 mc := memcache.Get(c) 67 mc := memcache.Get(c)
68 68
69 » » itmFor := func(i int, k datastore.Key) memcache.Item { 69 » » itmFor := func(i int, k *datastore.Key) memcache.Item {
70 return mc.NewItem(MakeMemcacheKey(i, k)) 70 return mc.NewItem(MakeMemcacheKey(i, k))
71 } 71 }
72 72
73 » » shardsForKey := func(k datastore.Key) int { 73 » » shardsForKey := func(k *datastore.Key) int {
74 » » » if k.Kind() == "shardObj" { 74 » » » last := k.Last()
iannucci 2015/09/18 04:31:52 Key changed a bit. Now instead of k.Kind(), you ge
75 » » » » return int(k.IntID()) 75 » » » if last.Kind == "shardObj" {
76 » » » » return int(last.IntID)
76 } 77 }
77 » » » if k.Kind() == "noCacheObj" { 78 » » » if last.Kind == "noCacheObj" {
78 return 0 79 return 0
79 } 80 }
80 return DefaultShards 81 return DefaultShards
81 } 82 }
82 83
83 numMemcacheItems := func() uint64 { 84 numMemcacheItems := func() uint64 {
84 stats, err := mc.Stats() 85 stats, err := mc.Stats()
85 So(err, ShouldBeNil) 86 So(err, ShouldBeNil)
86 return stats.Items 87 return stats.Items
87 } 88 }
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 InstanceEnabledStatic = false 448 InstanceEnabledStatic = false
448 defer func() { 449 defer func() {
449 InstanceEnabledStatic = true 450 InstanceEnabledStatic = true
450 }() 451 }()
451 452
452 c := context.Background() 453 c := context.Background()
453 newC := FilterRDS(c, nil) 454 newC := FilterRDS(c, nil)
454 So(newC, ShouldEqual, c) 455 So(newC, ShouldEqual, c)
455 }) 456 })
456 } 457 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698