| OLD | NEW |
| 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/mail" | 15 "github.com/luci/gae/service/mail" |
| 16 "github.com/luci/gae/service/memcache" | 16 "github.com/luci/gae/service/memcache" |
| 17 "github.com/luci/gae/service/module" |
| 17 "github.com/luci/gae/service/taskqueue" | 18 "github.com/luci/gae/service/taskqueue" |
| 18 "github.com/luci/gae/service/user" | 19 "github.com/luci/gae/service/user" |
| 19 "golang.org/x/net/context" | 20 "golang.org/x/net/context" |
| 20 ) | 21 ) |
| 21 | 22 |
| 22 const niFmtStr = "dummy: method %s.%s is not implemented" | 23 const niFmtStr = "dummy: method %s.%s is not implemented" |
| 23 | 24 |
| 24 // ni returns an error whose message is an appropriate expansion of niFmtStr. | 25 // ni returns an error whose message is an appropriate expansion of niFmtStr. |
| 25 // | 26 // |
| 26 // It walks the stack to find out what interface and method it's being | 27 // It walks the stack to find out what interface and method it's being |
| (...skipping 19 matching lines...) Expand all Loading... |
| 46 if len(parts) > 2 { | 47 if len(parts) > 2 { |
| 47 switch parts[len(parts)-2] { | 48 switch parts[len(parts)-2] { |
| 48 case "ds": | 49 case "ds": |
| 49 iface = "Datastore" | 50 iface = "Datastore" |
| 50 case "i": | 51 case "i": |
| 51 iface = "Info" | 52 iface = "Info" |
| 52 case "m": | 53 case "m": |
| 53 iface = "Mail" | 54 iface = "Mail" |
| 54 case "mc": | 55 case "mc": |
| 55 iface = "Memcache" | 56 iface = "Memcache" |
| 57 case "mod": |
| 58 iface = "Module" |
| 56 case "tq": | 59 case "tq": |
| 57 iface = "TaskQueue" | 60 iface = "TaskQueue" |
| 58 case "u": | 61 case "u": |
| 59 iface = "User" | 62 iface = "User" |
| 60 } | 63 } |
| 61 funcName = parts[len(parts)-1] | 64 funcName = parts[len(parts)-1] |
| 62 } | 65 } |
| 63 } | 66 } |
| 64 } | 67 } |
| 65 | 68 |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 func (m) Send(*mail.Message) error { panic(ni()) } | 197 func (m) Send(*mail.Message) error { panic(ni()) } |
| 195 func (m) SendToAdmins(*mail.Message) error { panic(ni()) } | 198 func (m) SendToAdmins(*mail.Message) error { panic(ni()) } |
| 196 func (m) Testable() mail.Testable { panic(ni()) } | 199 func (m) Testable() mail.Testable { panic(ni()) } |
| 197 | 200 |
| 198 var dummyMailInst = m{} | 201 var dummyMailInst = m{} |
| 199 | 202 |
| 200 // Mail returns a dummy mail.Interface implementation suitable for embedding. | 203 // Mail returns a dummy mail.Interface implementation suitable for embedding. |
| 201 // Every method panics with a message containing the name of the method which | 204 // Every method panics with a message containing the name of the method which |
| 202 // was unimplemented. | 205 // was unimplemented. |
| 203 func Mail() mail.Interface { return dummyMailInst } | 206 func Mail() mail.Interface { return dummyMailInst } |
| 207 |
| 208 /////////////////////////////////// mod //////////////////////////////////// |
| 209 |
| 210 type mod struct{} |
| 211 |
| 212 func (mod) List() ([]string, error) { panic(
ni()) } |
| 213 func (mod) NumInstances(module, version string) (int, error) { panic(
ni()) } |
| 214 func (mod) SetNumInstances(module, version string, instances int) error { panic(
ni()) } |
| 215 func (mod) Versions(module string) ([]string, error) { panic(
ni()) } |
| 216 func (mod) DefaultVersion(module string) (string, error) { panic(
ni()) } |
| 217 func (mod) Start(module, version string) error { panic(
ni()) } |
| 218 func (mod) Stop(module, version string) error { panic(
ni()) } |
| 219 |
| 220 var dummyModuleInst = mod{} |
| 221 |
| 222 // Module returns a dummy module.Interface implementation suitable for |
| 223 // embedding. Every method panics with a message containing the name of the |
| 224 // method which was unimplemented. |
| 225 func Module() module.Interface { return dummyModuleInst } |
| OLD | NEW |