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

Side by Side Diff: impl/dummy/dummy_test.go

Issue 1243323002: Refactor a bit. (Closed) Base URL: https://github.com/luci/gae.git@master
Patch Set: fix golint Created 5 years, 5 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 | « impl/dummy/dummy.go ('k') | impl/memory/README.md » ('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 package dummy 5 package dummy
6 6
7 import ( 7 import (
8 "testing" 8 "testing"
9 9
10 » "github.com/luci/gae" 10 » infoS "github.com/luci/gae/service/info"
11 » mcS "github.com/luci/gae/service/memcache"
12 » rdsS "github.com/luci/gae/service/rawdatastore"
13 » tqS "github.com/luci/gae/service/taskqueue"
11 . "github.com/smartystreets/goconvey/convey" 14 . "github.com/smartystreets/goconvey/convey"
12 "golang.org/x/net/context" 15 "golang.org/x/net/context"
13 ) 16 )
14 17
15 func TestContextAccess(t *testing.T) { 18 func TestContextAccess(t *testing.T) {
16 t.Parallel() 19 t.Parallel()
17 20
18 // p is a function which recovers an error and then immediately panics w ith 21 // p is a function which recovers an error and then immediately panics w ith
19 // the contained string. It's defer'd in each test so that we can use th e 22 // the contained string. It's defer'd in each test so that we can use th e
20 // ShouldPanicWith assertion (which does an == comparison and not 23 // ShouldPanicWith assertion (which does an == comparison and not
21 // a reflect.DeepEquals comparison). 24 // a reflect.DeepEquals comparison).
22 p := func() { panic(recover().(error).Error()) } 25 p := func() { panic(recover().(error).Error()) }
23 26
24 Convey("Context Access", t, func() { 27 Convey("Context Access", t, func() {
25 c := context.Background() 28 c := context.Background()
26 29
27 Convey("blank", func() { 30 Convey("blank", func() {
28 » » » So(gae.GetMC(c), ShouldBeNil) 31 » » » So(mcS.Get(c), ShouldBeNil)
29 » » » So(gae.GetTQ(c), ShouldBeNil) 32 » » » So(tqS.Get(c), ShouldBeNil)
30 » » » So(gae.GetGI(c), ShouldBeNil) 33 » » » So(infoS.Get(c), ShouldBeNil)
31 }) 34 })
32 35
33 » » Convey("RDS", func() { 36 » » Convey("RawDatastore", func() {
34 » » » c = gae.SetRDS(c, RDS()) 37 » » » c = rdsS.Set(c, RawDatastore())
35 » » » So(gae.GetRDS(c), ShouldNotBeNil) 38 » » » So(rdsS.Get(c), ShouldNotBeNil)
36 So(func() { 39 So(func() {
37 defer p() 40 defer p()
38 » » » » gae.GetRDS(c).NewKey("", "", 1, nil) 41 » » » » rdsS.Get(c).NewKey("", "", 1, nil)
39 }, ShouldPanicWith, "dummy: method RawDatastore.NewKey i s not implemented") 42 }, ShouldPanicWith, "dummy: method RawDatastore.NewKey i s not implemented")
40 }) 43 })
41 44
42 » » Convey("MC", func() { 45 » » Convey("Memcache", func() {
43 » » » c = gae.SetMC(c, MC()) 46 » » » c = mcS.Set(c, Memcache())
44 » » » So(gae.GetMC(c), ShouldNotBeNil) 47 » » » So(mcS.Get(c), ShouldNotBeNil)
45 So(func() { 48 So(func() {
46 defer p() 49 defer p()
47 » » » » gae.GetMC(c).Add(nil) 50 » » » » mcS.Get(c).Add(nil)
48 }, ShouldPanicWith, "dummy: method Memcache.Add is not i mplemented") 51 }, ShouldPanicWith, "dummy: method Memcache.Add is not i mplemented")
49 }) 52 })
50 53
51 » » Convey("TQ", func() { 54 » » Convey("TaskQueue", func() {
52 » » » c = gae.SetTQ(c, TQ()) 55 » » » c = tqS.Set(c, TaskQueue())
53 » » » So(gae.GetTQ(c), ShouldNotBeNil) 56 » » » So(tqS.Get(c), ShouldNotBeNil)
54 So(func() { 57 So(func() {
55 defer p() 58 defer p()
56 » » » » gae.GetTQ(c).Purge("") 59 » » » » tqS.Get(c).Purge("")
57 }, ShouldPanicWith, "dummy: method TaskQueue.Purge is no t implemented") 60 }, ShouldPanicWith, "dummy: method TaskQueue.Purge is no t implemented")
58 }) 61 })
59 62
60 » » Convey("GI", func() { 63 » » Convey("Info", func() {
61 » » » c = gae.SetGI(c, GI()) 64 » » » c = infoS.Set(c, Info())
62 » » » So(gae.GetGI(c), ShouldNotBeNil) 65 » » » So(infoS.Get(c), ShouldNotBeNil)
63 So(func() { 66 So(func() {
64 defer p() 67 defer p()
65 » » » » gae.GetGI(c).Datacenter() 68 » » » » infoS.Get(c).Datacenter()
66 » » » }, ShouldPanicWith, "dummy: method GlobalInfo.Datacenter is not implemented") 69 » » » }, ShouldPanicWith, "dummy: method Info.Datacenter is no t implemented")
67 » » })
68
69 » » Convey("QY", func() {
70 » » » q := QY()
71 » » » So(func() {
72 » » » » defer p()
73 » » » » q.Distinct()
74 » » » }, ShouldPanicWith, "dummy: method DSQuery.Distinct is n ot implemented")
75 }) 70 })
76 }) 71 })
77 } 72 }
OLDNEW
« no previous file with comments | « impl/dummy/dummy.go ('k') | impl/memory/README.md » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698