| 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/info" | 14 "github.com/luci/gae/service/info" |
| 14 "github.com/luci/gae/service/memcache" | 15 "github.com/luci/gae/service/memcache" |
| 15 "github.com/luci/gae/service/rawdatastore" | |
| 16 "github.com/luci/gae/service/taskqueue" | 16 "github.com/luci/gae/service/taskqueue" |
| 17 "golang.org/x/net/context" | 17 "golang.org/x/net/context" |
| 18 ) | 18 ) |
| 19 | 19 |
| 20 const niFmtStr = "dummy: method %s.%s is not implemented" | 20 const niFmtStr = "dummy: method %s.%s is not implemented" |
| 21 | 21 |
| 22 // ni returns an error whose message is an appropriate expansion of niFmtStr. | 22 // ni returns an error whose message is an appropriate expansion of niFmtStr. |
| 23 // | 23 // |
| 24 // It walks the stack to find out what interface and method it's being | 24 // 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: | 25 // called from. For example, it might return a message which looks like: |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 } | 57 } |
| 58 } | 58 } |
| 59 | 59 |
| 60 return fmt.Errorf(niFmtStr, iface, funcName) | 60 return fmt.Errorf(niFmtStr, iface, funcName) |
| 61 } | 61 } |
| 62 | 62 |
| 63 /////////////////////////////////// rds //////////////////////////////////// | 63 /////////////////////////////////// rds //////////////////////////////////// |
| 64 | 64 |
| 65 type rds struct{} | 65 type rds struct{} |
| 66 | 66 |
| 67 func (rds) NewKey(kind string, sid string, iid int64, par rawdatastore.Key) rawd
atastore.Key { | 67 func (rds) NewKey(kind string, sid string, iid int64, par datastore.Key) datasto
re.Key { |
| 68 » return rawdatastore.NewKey("dummy~appid", "", kind, sid, iid, par) | 68 » return datastore.NewKey("dummy~appid", "", kind, sid, iid, par) |
| 69 } | 69 } |
| 70 func (rds) DecodeKey(string) (rawdatastore.Key, error) { panic(ni()) } | 70 func (rds) DecodeKey(string) (datastore.Key, error) { panic(ni()) } |
| 71 func (rds) PutMulti([]rawdatastore.Key, []rawdatastore.PropertyLoadSaver, rawdat
astore.PutMultiCB) error { | 71 func (rds) PutMulti([]datastore.Key, []datastore.PropertyMap, datastore.PutMulti
CB) error { |
| 72 panic(ni()) | 72 panic(ni()) |
| 73 } | 73 } |
| 74 func (rds) GetMulti([]rawdatastore.Key, rawdatastore.GetMultiCB) error { p
anic(ni()) } | 74 func (rds) GetMulti([]datastore.Key, datastore.GetMultiCB) error { panic(n
i()) } |
| 75 func (rds) DeleteMulti([]rawdatastore.Key, rawdatastore.DeleteMultiCB) error { p
anic(ni()) } | 75 func (rds) DeleteMulti([]datastore.Key, datastore.DeleteMultiCB) error { panic(n
i()) } |
| 76 func (rds) NewQuery(string) rawdatastore.Query { p
anic(ni()) } | 76 func (rds) NewQuery(string) datastore.Query { panic(n
i()) } |
| 77 func (rds) Run(rawdatastore.Query, rawdatastore.RunCB) error { p
anic(ni()) } | 77 func (rds) Run(datastore.Query, datastore.RawRunCB) error { panic(n
i()) } |
| 78 func (rds) RunInTransaction(func(context.Context) error, *rawdatastore.Transacti
onOptions) error { | 78 func (rds) RunInTransaction(func(context.Context) error, *datastore.TransactionO
ptions) error { |
| 79 panic(ni()) | 79 panic(ni()) |
| 80 } | 80 } |
| 81 | 81 |
| 82 var dummyRDSInst = rds{} | 82 var dummyRDSInst = rds{} |
| 83 | 83 |
| 84 // RawDatastore returns a dummy rawdatastore.Interface implementation suitable | 84 // RawDatastore returns a dummy datastore.Interface implementation suitable |
| 85 // for embedding. Every method panics with a message containing the name of the | 85 // for embedding. Every method panics with a message containing the name of the |
| 86 // method which was unimplemented. | 86 // method which was unimplemented. |
| 87 func RawDatastore() rawdatastore.Interface { return dummyRDSInst } | 87 func RawDatastore() datastore.RawInterface { return dummyRDSInst } |
| 88 | 88 |
| 89 /////////////////////////////////// mc //////////////////////////////////// | 89 /////////////////////////////////// mc //////////////////////////////////// |
| 90 | 90 |
| 91 type mc struct{} | 91 type mc struct{} |
| 92 | 92 |
| 93 func (mc) Add(memcache.Item) error { panic(ni()) } | 93 func (mc) Add(memcache.Item) error { panic(ni()) } |
| 94 func (mc) NewItem(key string) memcache.Item { panic(ni()) } | 94 func (mc) NewItem(key string) memcache.Item { panic(ni()) } |
| 95 func (mc) Set(memcache.Item) error { panic(ni()) } | 95 func (mc) Set(memcache.Item) error { panic(ni()) } |
| 96 func (mc) Get(string) (memcache.Item, error) { panic(ni()) } | 96 func (mc) Get(string) (memcache.Item, error) { panic(ni()) } |
| 97 func (mc) Delete(string) error { panic(ni()) } | 97 func (mc) Delete(string) error { panic(ni()) } |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 func (i) IsCapabilityDisabled(err error) bool
{ panic(ni()) } | 157 func (i) IsCapabilityDisabled(err error) bool
{ panic(ni()) } |
| 158 func (i) IsOverQuota(err error) bool
{ panic(ni()) } | 158 func (i) IsOverQuota(err error) bool
{ panic(ni()) } |
| 159 func (i) IsTimeoutError(err error) bool
{ panic(ni()) } | 159 func (i) IsTimeoutError(err error) bool
{ panic(ni()) } |
| 160 | 160 |
| 161 var dummyInfoInst = i{} | 161 var dummyInfoInst = i{} |
| 162 | 162 |
| 163 // Info returns a dummy info.Interface implementation suitable for embedding. | 163 // Info returns a dummy info.Interface implementation suitable for embedding. |
| 164 // Every method panics with a message containing the name of the method which | 164 // Every method panics with a message containing the name of the method which |
| 165 // was unimplemented. | 165 // was unimplemented. |
| 166 func Info() info.Interface { return dummyInfoInst } | 166 func Info() info.Interface { return dummyInfoInst } |
| OLD | NEW |