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

Unified Diff: luci_config/appengine/backend/datastore/ds_test.go

Issue 2640813005: Fold config service URL into datastore cache keys. (Closed)
Patch Set: Rebase. Created 3 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | luci_config/appengine/backend/memcache/cache_test.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: luci_config/appengine/backend/datastore/ds_test.go
diff --git a/luci_config/appengine/backend/datastore/ds_test.go b/luci_config/appengine/backend/datastore/ds_test.go
index 001f8ac0b125a0d6b95f21f31170ac5451e97221..3992b879db54b99b17e75be76fc70788b3817599 100644
--- a/luci_config/appengine/backend/datastore/ds_test.go
+++ b/luci_config/appengine/backend/datastore/ds_test.go
@@ -58,13 +58,15 @@ func projectConfigWithAccess(name cfgtypes.ProjectName, access ...string) *confi
// fakeCache is a pure in-memory testCache implementation. It is very simple,
// storing only raw cache key/value pairs.
type fakeCache struct {
- d map[string]datastorecache.Value
- err error
+ d map[string]datastorecache.Value
+ serviceURL string
+ err error
}
-func mkFakeCache() *fakeCache {
+func mkFakeCache(serviceURL string) *fakeCache {
return &fakeCache{
- d: make(map[string]datastorecache.Value),
+ d: make(map[string]datastorecache.Value),
+ serviceURL: serviceURL,
}
}
@@ -85,9 +87,6 @@ func (fc *fakeCache) Get(c context.Context, key []byte) (v datastorecache.Value,
return
}
-func (fc *fakeCache) setCacheData(key caching.Key, d []byte) {
-}
-
func (fc *fakeCache) set(key caching.Key, v *caching.Value) {
encKey, err := caching.Encode(&key)
if err != nil {
@@ -116,10 +115,11 @@ func (fc *fakeCache) setCacheErr(err error) { fc.err = err }
func (fc *fakeCache) setProjectDNE(project string) {
// Get for this project config will fail.
fc.set(caching.Key{
- Schema: caching.Schema,
- Op: caching.OpGet,
- ConfigSet: string(cfgtypes.ProjectConfigSet(cfgtypes.ProjectName(project))),
- Path: cfgclient.ProjectConfigPath,
+ Schema: caching.Schema,
+ ServiceURL: fc.serviceURL,
+ Op: caching.OpGet,
+ ConfigSet: string(cfgtypes.ProjectConfigSet(cfgtypes.ProjectName(project))),
+ Path: cfgclient.ProjectConfigPath,
}, nil)
}
@@ -143,6 +143,7 @@ func (fc *fakeCache) addConfigImpl(cs cfgtypes.ConfigSet, path, formatter, forma
fc.set(caching.Key{
Schema: caching.Schema,
+ ServiceURL: fc.serviceURL,
Authority: backend.AsService,
Op: caching.OpGet,
ConfigSet: string(cs),
@@ -197,6 +198,7 @@ func (fc *fakeCache) addConfigSets(path string, configSets ...cfgtypes.ConfigSet
fc.set(caching.Key{
Schema: caching.Schema,
+ ServiceURL: fc.serviceURL,
Authority: backend.AsService,
Op: caching.OpGetAll,
Content: true,
@@ -210,10 +212,11 @@ func (fc *fakeCache) addConfigSets(path string, configSets ...cfgtypes.ConfigSet
func (fc *fakeCache) addConfigSetURL(configSet cfgtypes.ConfigSet) string {
u := fmt.Sprintf("https://exmaple.com/config-sets/%s", configSet)
fc.set(caching.Key{
- Schema: caching.Schema,
- Authority: backend.AsService,
- Op: caching.OpConfigSetURL,
- ConfigSet: string(configSet),
+ Schema: caching.Schema,
+ ServiceURL: fc.serviceURL,
+ Authority: backend.AsService,
+ Op: caching.OpConfigSetURL,
+ ConfigSet: string(configSet),
}, &caching.Value{
URL: u,
})
@@ -554,14 +557,14 @@ func TestDatastoreCache(t *testing.T) {
Convey(`Testing with in-memory stub cache`, t, func() {
c := context.Background()
- fc := mkFakeCache()
- var be backend.B
- be = &client.Backend{
+ var be backend.B = &client.Backend{
Provider: &testconfig.Provider{
Base: memConfig.New(nil),
},
}
+ mcURL := be.ServiceURL(c)
+ fc := mkFakeCache(mcURL.String())
fr := gaeformat.Default()
be = &format.Backend{
« no previous file with comments | « no previous file | luci_config/appengine/backend/memcache/cache_test.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698