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

Side by Side Diff: impl/cloud/datastore_test.go

Issue 2513253002: impl/cloud: Add support for "memcached" memcache. (Closed)
Patch Set: Add test for key hasing. Created 4 years 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 | « impl/cloud/context.go ('k') | impl/cloud/memcache.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 2016 The LUCI Authors. All rights reserved. 1 // Copyright 2016 The LUCI Authors. All rights reserved.
2 // Use of this source code is governed under the Apache License, Version 2.0 2 // Use of this source code is governed under the Apache License, Version 2.0
3 // that can be found in the LICENSE file. 3 // that can be found in the LICENSE file.
4 4
5 package cloud 5 package cloud
6 6
7 import ( 7 import (
8 "crypto/rand" 8 "crypto/rand"
9 "encoding/hex" 9 "encoding/hex"
10 "fmt" 10 "fmt"
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 // $ export DATASTORE_EMULATOR_HOST=localhost:8080 62 // $ export DATASTORE_EMULATOR_HOST=localhost:8080
63 // 63 //
64 // If the emulator environment is not detected, this test will be skipped. 64 // If the emulator environment is not detected, this test will be skipped.
65 func TestDatastore(t *testing.T) { 65 func TestDatastore(t *testing.T) {
66 t.Parallel() 66 t.Parallel()
67 67
68 // See if an emulator is running. If no emulator is running, we will ski p this 68 // See if an emulator is running. If no emulator is running, we will ski p this
69 // test suite. 69 // test suite.
70 emulatorHost := os.Getenv("DATASTORE_EMULATOR_HOST") 70 emulatorHost := os.Getenv("DATASTORE_EMULATOR_HOST")
71 if emulatorHost == "" { 71 if emulatorHost == "" {
72 » » t.Logf("No emulator detected. Skipping test suite.") 72 » » t.Logf("No emulator detected (DATASTORE_EMULATOR_HOST). Skipping test suite.")
73 return 73 return
74 } 74 }
75 75
76 Convey(fmt.Sprintf(`A cloud installation using datastore emulator %q`, e mulatorHost), t, func() { 76 Convey(fmt.Sprintf(`A cloud installation using datastore emulator %q`, e mulatorHost), t, func() {
77 c := context.Background() 77 c := context.Background()
78 client, err := datastore.NewClient(c, "luci-gae-test") 78 client, err := datastore.NewClient(c, "luci-gae-test")
79 So(err, ShouldBeNil) 79 So(err, ShouldBeNil)
80 defer client.Close() 80 defer client.Close()
81 81
82 testTime := ds.RoundTime(time.Date(2016, 1, 1, 0, 0, 0, 0, time. UTC)) 82 testTime := ds.RoundTime(time.Date(2016, 1, 1, 0, 0, 0, 0, time. UTC))
83 _ = testTime 83 _ = testTime
84 84
85 » » c = Use(c, client) 85 » » cfg := Config{DS: client}
86 » » c = cfg.Use(c)
86 87
87 Convey(`Supports namespaces`, func() { 88 Convey(`Supports namespaces`, func() {
88 namespaces := []string{"foo", "bar", "baz"} 89 namespaces := []string{"foo", "bar", "baz"}
89 90
90 // Clear all used entities from all namespaces. 91 // Clear all used entities from all namespaces.
91 for _, ns := range namespaces { 92 for _, ns := range namespaces {
92 nsCtx := info.MustNamespace(c, ns) 93 nsCtx := info.MustNamespace(c, ns)
93 94
94 keys := make([]*ds.Key, len(namespaces)) 95 keys := make([]*ds.Key, len(namespaces))
95 for i := range keys { 96 for i := range keys {
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 pmap := ds.PropertyMap{"$kind": mkp("Tes t"), "$id": mkp("quux")} 307 pmap := ds.PropertyMap{"$kind": mkp("Tes t"), "$id": mkp("quux")}
307 err = ds.RunInTransaction(c, func(c cont ext.Context) error { 308 err = ds.RunInTransaction(c, func(c cont ext.Context) error {
308 return ds.Get(c, pmap) 309 return ds.Get(c, pmap)
309 }, nil) 310 }, nil)
310 So(err, ShouldEqual, ds.ErrNoSuchEntity) 311 So(err, ShouldEqual, ds.ErrNoSuchEntity)
311 }) 312 })
312 }) 313 })
313 }) 314 })
314 }) 315 })
315 } 316 }
OLDNEW
« no previous file with comments | « impl/cloud/context.go ('k') | impl/cloud/memcache.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698