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

Side by Side Diff: 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 | « dummy/dummy.go ('k') | filters/count/count_test.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 package dummy
6
7 import (
8 "testing"
9
10 "github.com/luci/gae"
11 . "github.com/smartystreets/goconvey/convey"
12 "golang.org/x/net/context"
13 )
14
15 func TestContextAccess(t *testing.T) {
16 t.Parallel()
17
18 // 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
20 // ShouldPanicWith assertion (which does an == comparison and not
21 // a reflect.DeepEquals comparison).
22 p := func() { panic(recover().(error).Error()) }
23
24 Convey("Context Access", t, func() {
25 c := context.Background()
26
27 Convey("blank", func() {
28 So(gae.GetMC(c), ShouldBeNil)
29 So(gae.GetTQ(c), ShouldBeNil)
30 So(gae.GetGI(c), ShouldBeNil)
31 })
32
33 Convey("RDS", func() {
34 c = gae.SetRDS(c, RDS())
35 So(gae.GetRDS(c), ShouldNotBeNil)
36 So(func() {
37 defer p()
38 gae.GetRDS(c).NewKey("", "", 1, nil)
39 }, ShouldPanicWith, "dummy: method RawDatastore.NewKey i s not implemented")
40 })
41
42 Convey("MC", func() {
43 c = gae.SetMC(c, MC())
44 So(gae.GetMC(c), ShouldNotBeNil)
45 So(func() {
46 defer p()
47 gae.GetMC(c).Add(nil)
48 }, ShouldPanicWith, "dummy: method Memcache.Add is not i mplemented")
49 })
50
51 Convey("TQ", func() {
52 c = gae.SetTQ(c, TQ())
53 So(gae.GetTQ(c), ShouldNotBeNil)
54 So(func() {
55 defer p()
56 gae.GetTQ(c).Purge("")
57 }, ShouldPanicWith, "dummy: method TaskQueue.Purge is no t implemented")
58 })
59
60 Convey("GI", func() {
61 c = gae.SetGI(c, GI())
62 So(gae.GetGI(c), ShouldNotBeNil)
63 So(func() {
64 defer p()
65 gae.GetGI(c).Datacenter()
66 }, ShouldPanicWith, "dummy: method GlobalInfo.Datacenter is not 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 })
76 })
77 }
OLDNEW
« no previous file with comments | « dummy/dummy.go ('k') | filters/count/count_test.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698