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

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

Issue 1500433002: Add User service. (Closed) Base URL: https://github.com/luci/gae.git@inner_ctx
Patch Set: method Created 5 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 | « no previous file | impl/dummy/dummy_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
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 "fmt" 8 "fmt"
9 "runtime" 9 "runtime"
10 "strings" 10 "strings"
11 "time" 11 "time"
12 12
13 "github.com/luci/gae/service/datastore" 13 "github.com/luci/gae/service/datastore"
14 "github.com/luci/gae/service/info" 14 "github.com/luci/gae/service/info"
15 "github.com/luci/gae/service/memcache" 15 "github.com/luci/gae/service/memcache"
16 "github.com/luci/gae/service/taskqueue" 16 "github.com/luci/gae/service/taskqueue"
17 "github.com/luci/gae/service/user"
17 "golang.org/x/net/context" 18 "golang.org/x/net/context"
18 ) 19 )
19 20
20 const niFmtStr = "dummy: method %s.%s is not implemented" 21 const niFmtStr = "dummy: method %s.%s is not implemented"
21 22
22 // ni returns an error whose message is an appropriate expansion of niFmtStr. 23 // ni returns an error whose message is an appropriate expansion of niFmtStr.
23 // 24 //
24 // It walks the stack to find out what interface and method it's being 25 // It walks the stack to find out what interface and method it's being
25 // called from. For example, it might return a message which looks like: 26 // called from. For example, it might return a message which looks like:
26 // dummy: method Datastore.Get is not implemented 27 // dummy: method Datastore.Get is not implemented
(...skipping 11 matching lines...) Expand all
38 39
39 if ptr, _, _, ok := runtime.Caller(1); ok { 40 if ptr, _, _, ok := runtime.Caller(1); ok {
40 f := runtime.FuncForPC(ptr) 41 f := runtime.FuncForPC(ptr)
41 n := f.Name() 42 n := f.Name()
42 if n != "" { 43 if n != "" {
43 parts := strings.Split(n, ".") 44 parts := strings.Split(n, ".")
44 if len(parts) > 2 { 45 if len(parts) > 2 {
45 switch parts[len(parts)-2] { 46 switch parts[len(parts)-2] {
46 case "ds": 47 case "ds":
47 iface = "Datastore" 48 iface = "Datastore"
49 case "i":
50 iface = "Info"
48 case "mc": 51 case "mc":
49 iface = "Memcache" 52 iface = "Memcache"
50 case "tq": 53 case "tq":
51 iface = "TaskQueue" 54 iface = "TaskQueue"
52 » » » » case "i": 55 » » » » case "u":
53 » » » » » iface = "Info" 56 » » » » » iface = "User"
54 } 57 }
55 funcName = parts[len(parts)-1] 58 funcName = parts[len(parts)-1]
56 } 59 }
57 } 60 }
58 } 61 }
59 62
60 return fmt.Errorf(niFmtStr, iface, funcName) 63 return fmt.Errorf(niFmtStr, iface, funcName)
61 } 64 }
62 65
63 /////////////////////////////////// ds //////////////////////////////////// 66 /////////////////////////////////// ds ////////////////////////////////////
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 func (i) IsCapabilityDisabled(err error) bool { panic(ni()) } 155 func (i) IsCapabilityDisabled(err error) bool { panic(ni()) }
153 func (i) IsOverQuota(err error) bool { panic(ni()) } 156 func (i) IsOverQuota(err error) bool { panic(ni()) }
154 func (i) IsTimeoutError(err error) bool { panic(ni()) } 157 func (i) IsTimeoutError(err error) bool { panic(ni()) }
155 158
156 var dummyInfoInst = i{} 159 var dummyInfoInst = i{}
157 160
158 // Info returns a dummy info.Interface implementation suitable for embedding. 161 // Info returns a dummy info.Interface implementation suitable for embedding.
159 // Every method panics with a message containing the name of the method which 162 // Every method panics with a message containing the name of the method which
160 // was unimplemented. 163 // was unimplemented.
161 func Info() info.Interface { return dummyInfoInst } 164 func Info() info.Interface { return dummyInfoInst }
165
166 ////////////////////////////////////// u ///////////////////////////////////////
167
168 type u struct{}
169
170 func (u) Current() *user.User { panic(ni()) }
171 func (u) CurrentOAuth() (*user.User, error) { panic(ni()) }
172 func (u) IsAdmin() bool { panic(ni()) }
173 func (u) LoginURL(string) (string, error) { panic(ni()) }
174 func (u) LoginURLFederated(string, string) (string, error) { panic(ni()) }
175 func (u) LogoutURL(string) (string, error) { panic(ni()) }
176 func (u) OAuthConsumerKey() (string, error) { panic(ni()) }
177
178 var dummyUserInst = u{}
179
180 // User returns a dummy user.Interface implementation suitable for embedding.
181 // Every method panics with a message containing the name of the method which
182 // was unimplemented.
183 func User() user.Interface { return dummyUserInst }
OLDNEW
« no previous file with comments | « no previous file | impl/dummy/dummy_test.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698