| OLD | NEW |
| 1 // Copyright 2015 The LUCI Authors. All rights reserved. | 1 // Copyright 2015 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 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/module" |
| 18 "github.com/luci/gae/service/taskqueue" | 18 "github.com/luci/gae/service/taskqueue" |
| 19 "github.com/luci/gae/service/user" | 19 "github.com/luci/gae/service/user" |
| 20 |
| 20 "golang.org/x/net/context" | 21 "golang.org/x/net/context" |
| 21 ) | 22 ) |
| 22 | 23 |
| 23 const niFmtStr = "dummy: method %s.%s is not implemented" | 24 const niFmtStr = "dummy: method %s.%s is not implemented" |
| 24 | 25 |
| 25 // ni returns an error whose message is an appropriate expansion of niFmtStr. | 26 // ni returns an error whose message is an appropriate expansion of niFmtStr. |
| 26 // | 27 // |
| 27 // It walks the stack to find out what interface and method it's being | 28 // It walks the stack to find out what interface and method it's being |
| 28 // called from. For example, it might return a message which looks like: | 29 // called from. For example, it might return a message which looks like: |
| 29 // dummy: method Datastore.Get is not implemented | 30 // dummy: method Datastore.Get is not implemented |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 } | 67 } |
| 67 } | 68 } |
| 68 | 69 |
| 69 return fmt.Errorf(niFmtStr, iface, funcName) | 70 return fmt.Errorf(niFmtStr, iface, funcName) |
| 70 } | 71 } |
| 71 | 72 |
| 72 /////////////////////////////////// ds //////////////////////////////////// | 73 /////////////////////////////////// ds //////////////////////////////////// |
| 73 | 74 |
| 74 type ds struct{} | 75 type ds struct{} |
| 75 | 76 |
| 76 func (ds) AllocateIDs([]*datastore.Key, datastore.NewKeyCB) error
{ panic(ni()) } | 77 func (ds) AllocateIDs([]*datastore.Key, datastore.NewKeyCB) error { panic(ni())
} |
| 77 func (ds) PutMulti([]*datastore.Key, []datastore.PropertyMap, datastore.NewKeyCB
) error { panic(ni()) } | 78 func (ds) PutMulti([]*datastore.Key, []datastore.PropertyMap, datastore.NewKeyCB
) error { |
| 79 » panic(ni()) |
| 80 } |
| 78 func (ds) GetMulti([]*datastore.Key, datastore.MultiMetaGetter, datastore.GetMul
tiCB) error { | 81 func (ds) GetMulti([]*datastore.Key, datastore.MultiMetaGetter, datastore.GetMul
tiCB) error { |
| 79 panic(ni()) | 82 panic(ni()) |
| 80 } | 83 } |
| 81 func (ds) DeleteMulti([]*datastore.Key, datastore.DeleteMultiCB) error { panic(n
i()) } | 84 func (ds) DeleteMulti([]*datastore.Key, datastore.DeleteMultiCB) error { panic(n
i()) } |
| 82 func (ds) DecodeCursor(string) (datastore.Cursor, error) { panic(n
i()) } | 85 func (ds) DecodeCursor(string) (datastore.Cursor, error) { panic(n
i()) } |
| 83 func (ds) Count(*datastore.FinalizedQuery) (int64, error) { panic(n
i()) } | 86 func (ds) Count(*datastore.FinalizedQuery) (int64, error) { panic(n
i()) } |
| 84 func (ds) Run(*datastore.FinalizedQuery, datastore.RawRunCB) error { panic(n
i()) } | 87 func (ds) Run(*datastore.FinalizedQuery, datastore.RawRunCB) error { panic(n
i()) } |
| 85 func (ds) RunInTransaction(func(context.Context) error, *datastore.TransactionOp
tions) error { | 88 func (ds) RunInTransaction(func(context.Context) error, *datastore.TransactionOp
tions) error { |
| 86 panic(ni()) | 89 panic(ni()) |
| 87 } | 90 } |
| 88 func (ds) Testable() datastore.Testable { return nil } | 91 func (ds) WithTransaction(datastore.Transaction) context.Context { panic(ni()) } |
| 92 func (ds) CurrentTransaction() datastore.Transaction { panic(ni()) } |
| 93 |
| 94 func (ds) GetTestable() datastore.Testable { return nil } |
| 89 | 95 |
| 90 var dummyDSInst = ds{} | 96 var dummyDSInst = ds{} |
| 91 | 97 |
| 92 // Datastore returns a dummy datastore.RawInterface implementation suitable | 98 // Datastore returns a dummy datastore.RawInterface implementation suitable |
| 93 // for embedding. Every method panics with a message containing the name of the | 99 // for embedding. Every method panics with a message containing the name of the |
| 94 // method which was unimplemented. | 100 // method which was unimplemented. |
| 95 func Datastore() datastore.RawInterface { return dummyDSInst } | 101 func Datastore() datastore.RawInterface { return dummyDSInst } |
| 96 | 102 |
| 97 /////////////////////////////////// mc //////////////////////////////////// | 103 /////////////////////////////////// mc //////////////////////////////////// |
| 98 | 104 |
| 99 type mc struct{} | 105 type mc struct{} |
| 100 | 106 |
| 101 func (mc) NewItem(key string) memcache.Item { panic(ni(
)) } | 107 func (mc) NewItem(string) memcache.Item { panic(ni(
)) } |
| 102 func (mc) AddMulti([]memcache.Item, memcache.RawCB) error { panic(ni(
)) } | 108 func (mc) AddMulti([]memcache.Item, memcache.RawCB) error { panic(ni(
)) } |
| 103 func (mc) SetMulti([]memcache.Item, memcache.RawCB) error { panic(ni(
)) } | 109 func (mc) SetMulti([]memcache.Item, memcache.RawCB) error { panic(ni(
)) } |
| 104 func (mc) GetMulti([]string, memcache.RawItemCB) error { panic(ni(
)) } | 110 func (mc) GetMulti([]string, memcache.RawItemCB) error { panic(ni(
)) } |
| 105 func (mc) DeleteMulti([]string, memcache.RawCB) error { panic(ni(
)) } | 111 func (mc) DeleteMulti([]string, memcache.RawCB) error { panic(ni(
)) } |
| 106 func (mc) CompareAndSwapMulti([]memcache.Item, memcache.RawCB) error { panic(ni(
)) } | 112 func (mc) CompareAndSwapMulti([]memcache.Item, memcache.RawCB) error { panic(ni(
)) } |
| 107 func (mc) Increment(string, int64, *uint64) (uint64, error) { panic(ni(
)) } | 113 func (mc) Increment(string, int64, *uint64) (uint64, error) { panic(ni(
)) } |
| 108 func (mc) Flush() error { panic(ni(
)) } | 114 func (mc) Flush() error { panic(ni(
)) } |
| 109 func (mc) Stats() (*memcache.Statistics, error) { panic(ni(
)) } | 115 func (mc) Stats() (*memcache.Statistics, error) { panic(ni(
)) } |
| 110 | 116 |
| 111 var dummyMCInst = mc{} | 117 var dummyMCInst = mc{} |
| 112 | 118 |
| 113 // Memcache returns a dummy memcache.RawInterface implementation suitable for | 119 // Memcache returns a dummy memcache.RawInterface implementation suitable for |
| 114 // embedding. Every method panics with a message containing the name of the | 120 // embedding. Every method panics with a message containing the name of the |
| 115 // method which was unimplemented. | 121 // method which was unimplemented. |
| 116 func Memcache() memcache.RawInterface { return dummyMCInst } | 122 func Memcache() memcache.RawInterface { return dummyMCInst } |
| 117 | 123 |
| 118 /////////////////////////////////// tq //////////////////////////////////// | 124 /////////////////////////////////// tq //////////////////////////////////// |
| 119 | 125 |
| 120 type tq struct{} | 126 type tq struct{} |
| 121 | 127 |
| 122 func (tq) AddMulti([]*taskqueue.Task, string, taskqueue.RawTaskCB) error { panic
(ni()) } | 128 func (tq) AddMulti([]*taskqueue.Task, string, taskqueue.RawTaskCB) error { panic
(ni()) } |
| 123 func (tq) DeleteMulti([]*taskqueue.Task, string, taskqueue.RawCB) error { panic
(ni()) } | 129 func (tq) DeleteMulti([]*taskqueue.Task, string, taskqueue.RawCB) error { panic
(ni()) } |
| 124 func (tq) Purge(string) error { panic
(ni()) } | 130 func (tq) Purge(string) error { panic
(ni()) } |
| 125 func (tq) Stats([]string, taskqueue.RawStatsCB) error { panic
(ni()) } | 131 func (tq) Stats([]string, taskqueue.RawStatsCB) error { panic
(ni()) } |
| 126 func (tq) Testable() taskqueue.Testable { retur
n nil } | 132 func (tq) GetTestable() taskqueue.Testable { retur
n nil } |
| 127 | 133 |
| 128 var dummyTQInst = tq{} | 134 var dummyTQInst = tq{} |
| 129 | 135 |
| 130 // TaskQueue returns a dummy taskqueue.RawInterface implementation suitable for | 136 // TaskQueue returns a dummy taskqueue.RawInterface implementation suitable for |
| 131 // embedding. Every method panics with a message containing the name of the | 137 // embedding. Every method panics with a message containing the name of the |
| 132 // method which was unimplemented. | 138 // method which was unimplemented. |
| 133 func TaskQueue() taskqueue.RawInterface { return dummyTQInst } | 139 func TaskQueue() taskqueue.RawInterface { return dummyTQInst } |
| 134 | 140 |
| 135 /////////////////////////////////// i //////////////////////////////////// | 141 /////////////////////////////////// i //////////////////////////////////// |
| 136 | 142 |
| 137 type i struct{} | 143 type i struct{} |
| 138 | 144 |
| 139 func (i) AccessToken(scopes ...string) (token string, expiry time.Time, err erro
r) { panic(ni()) } | 145 func (i) AccessToken(...string) (token string, expiry time.Time, err error) { |
| 140 func (i) AppID() string
{ return "appid" } | 146 » panic(ni()) |
| 141 func (i) FullyQualifiedAppID() string
{ return "dummy~appid" } | 147 } |
| 142 func (i) GetNamespace() (string, bool)
{ return "dummy-namespace", true } | 148 func (i) AppID() string { return "appid" } |
| 143 func (i) ModuleHostname(module, version, instance string) (string, error)
{ panic(ni()) } | 149 func (i) FullyQualifiedAppID() string { return "dummy~appid" } |
| 144 func (i) ModuleName() string
{ panic(ni()) } | 150 func (i) GetNamespace() string { return "dummy-namespace" } |
| 145 func (i) DefaultVersionHostname() string
{ panic(ni()) } | 151 func (i) ModuleHostname(module, version, instance string) (string, error) { |
| 146 func (i) PublicCertificates() ([]info.Certificate, error)
{ panic(ni()) } | 152 » panic(ni()) |
| 147 func (i) RequestID() string
{ panic(ni()) } | 153 } |
| 148 func (i) ServiceAccount() (string, error)
{ panic(ni()) } | 154 func (i) ModuleName() string { panic
(ni()) } |
| 149 func (i) SignBytes(bytes []byte) (keyName string, signature []byte, err error)
{ panic(ni()) } | 155 func (i) DefaultVersionHostname() string { panic
(ni()) } |
| 150 func (i) VersionID() string
{ panic(ni()) } | 156 func (i) PublicCertificates() ([]info.Certificate, error) { panic
(ni()) } |
| 151 func (i) Namespace(namespace string) (context.Context, error)
{ panic(ni()) } | 157 func (i) RequestID() string { panic
(ni()) } |
| 152 func (i) Datacenter() string
{ panic(ni()) } | 158 func (i) ServiceAccount() (string, error) { panic
(ni()) } |
| 153 func (i) InstanceID() string
{ panic(ni()) } | 159 func (i) SignBytes([]byte) (keyName string, signature []byte, err error) { panic
(ni()) } |
| 154 func (i) IsDevAppServer() bool
{ panic(ni()) } | 160 func (i) VersionID() string { panic
(ni()) } |
| 155 func (i) ServerSoftware() string
{ panic(ni()) } | 161 func (i) Namespace(string) (context.Context, error) { panic
(ni()) } |
| 156 func (i) IsCapabilityDisabled(err error) bool
{ panic(ni()) } | 162 func (i) Datacenter() string { panic
(ni()) } |
| 157 func (i) IsOverQuota(err error) bool
{ panic(ni()) } | 163 func (i) InstanceID() string { panic
(ni()) } |
| 158 func (i) IsTimeoutError(err error) bool
{ panic(ni()) } | 164 func (i) IsDevAppServer() bool { panic
(ni()) } |
| 159 func (i) Testable() info.Testable
{ panic(ni()) } | 165 func (i) ServerSoftware() string { panic
(ni()) } |
| 166 func (i) IsCapabilityDisabled(error) bool { panic
(ni()) } |
| 167 func (i) IsOverQuota(error) bool { panic
(ni()) } |
| 168 func (i) IsTimeoutError(error) bool { panic
(ni()) } |
| 169 func (i) GetTestable() info.Testable { panic
(ni()) } |
| 160 | 170 |
| 161 var dummyInfoInst = i{} | 171 var dummyInfoInst = i{} |
| 162 | 172 |
| 163 // Info returns a dummy info.RawInterface implementation suitable for embedding. | 173 // Info returns a dummy info.RawInterface implementation suitable for embedding. |
| 164 // Every method panics with a message containing the name of the method which | 174 // Every method panics with a message containing the name of the method which |
| 165 // was unimplemented. | 175 // was unimplemented. |
| 166 func Info() info.RawInterface { return dummyInfoInst } | 176 func Info() info.RawInterface { return dummyInfoInst } |
| 167 | 177 |
| 168 ////////////////////////////////////// u /////////////////////////////////////// | 178 ////////////////////////////////////// u /////////////////////////////////////// |
| 169 | 179 |
| 170 type u struct{} | 180 type u struct{} |
| 171 | 181 |
| 172 func (u) Current() *user.User { panic(ni()) } | 182 func (u) Current() *user.User { panic(ni()) } |
| 173 func (u) CurrentOAuth(...string) (*user.User, error) { panic(ni()) } | 183 func (u) CurrentOAuth(...string) (*user.User, error) { panic(ni()) } |
| 174 func (u) IsAdmin() bool { panic(ni()) } | 184 func (u) IsAdmin() bool { panic(ni()) } |
| 175 func (u) LoginURL(string) (string, error) { panic(ni()) } | 185 func (u) LoginURL(string) (string, error) { panic(ni()) } |
| 176 func (u) LoginURLFederated(string, string) (string, error) { panic(ni()) } | 186 func (u) LoginURLFederated(string, string) (string, error) { panic(ni()) } |
| 177 func (u) LogoutURL(string) (string, error) { panic(ni()) } | 187 func (u) LogoutURL(string) (string, error) { panic(ni()) } |
| 178 func (u) OAuthConsumerKey() (string, error) { panic(ni()) } | 188 func (u) OAuthConsumerKey() (string, error) { panic(ni()) } |
| 179 func (u) Testable() user.Testable { panic(ni()) } | 189 func (u) GetTestable() user.Testable { panic(ni()) } |
| 180 | 190 |
| 181 var dummyUserInst = u{} | 191 var dummyUserInst = u{} |
| 182 | 192 |
| 183 // User returns a dummy user.Interface implementation suitable for embedding. | 193 // User returns a dummy user.Interface implementation suitable for embedding. |
| 184 // Every method panics with a message containing the name of the method which | 194 // Every method panics with a message containing the name of the method which |
| 185 // was unimplemented. | 195 // was unimplemented. |
| 186 func User() user.Interface { return dummyUserInst } | 196 func User() user.RawInterface { return dummyUserInst } |
| 187 | 197 |
| 188 ////////////////////////////////////// m /////////////////////////////////////// | 198 ////////////////////////////////////// m /////////////////////////////////////// |
| 189 | 199 |
| 190 type m struct{} | 200 type m struct{} |
| 191 | 201 |
| 192 func (m) Send(*mail.Message) error { panic(ni()) } | 202 func (m) Send(*mail.Message) error { panic(ni()) } |
| 193 func (m) SendToAdmins(*mail.Message) error { panic(ni()) } | 203 func (m) SendToAdmins(*mail.Message) error { panic(ni()) } |
| 194 func (m) Testable() mail.Testable { panic(ni()) } | 204 func (m) GetTestable() mail.Testable { panic(ni()) } |
| 195 | 205 |
| 196 var dummyMailInst = m{} | 206 var dummyMailInst = m{} |
| 197 | 207 |
| 198 // Mail returns a dummy mail.Interface implementation suitable for embedding. | 208 // Mail returns a dummy mail.Interface implementation suitable for embedding. |
| 199 // Every method panics with a message containing the name of the method which | 209 // Every method panics with a message containing the name of the method which |
| 200 // was unimplemented. | 210 // was unimplemented. |
| 201 func Mail() mail.Interface { return dummyMailInst } | 211 func Mail() mail.RawInterface { return dummyMailInst } |
| 202 | 212 |
| 203 /////////////////////////////////// mod //////////////////////////////////// | 213 /////////////////////////////////// mod //////////////////////////////////// |
| 204 | 214 |
| 205 type mod struct{} | 215 type mod struct{} |
| 206 | 216 |
| 207 func (mod) List() ([]string, error) { panic(
ni()) } | 217 func (mod) List() ([]string, error) { panic(ni()) } |
| 208 func (mod) NumInstances(module, version string) (int, error) { panic(
ni()) } | 218 func (mod) NumInstances(module, version string) (int, error) { panic(ni()) } |
| 209 func (mod) SetNumInstances(module, version string, instances int) error { panic(
ni()) } | 219 func (mod) SetNumInstances(module, version string, instances int) error { |
| 210 func (mod) Versions(module string) ([]string, error) { panic(
ni()) } | 220 » panic(ni()) |
| 211 func (mod) DefaultVersion(module string) (string, error) { panic(
ni()) } | 221 } |
| 212 func (mod) Start(module, version string) error { panic(
ni()) } | 222 func (mod) Versions(module string) ([]string, error) { panic(ni()) } |
| 213 func (mod) Stop(module, version string) error { panic(
ni()) } | 223 func (mod) DefaultVersion(module string) (string, error) { panic(ni()) } |
| 224 func (mod) Start(module, version string) error { panic(ni()) } |
| 225 func (mod) Stop(module, version string) error { panic(ni()) } |
| 214 | 226 |
| 215 var dummyModuleInst = mod{} | 227 var dummyModuleInst = mod{} |
| 216 | 228 |
| 217 // Module returns a dummy module.Interface implementation suitable for | 229 // Module returns a dummy module.Interface implementation suitable for |
| 218 // embedding. Every method panics with a message containing the name of the | 230 // embedding. Every method panics with a message containing the name of the |
| 219 // method which was unimplemented. | 231 // method which was unimplemented. |
| 220 func Module() module.Interface { return dummyModuleInst } | 232 func Module() module.RawInterface { return dummyModuleInst } |
| OLD | NEW |