Documentation ¶
Overview ¶
Package appenginetesting provides an appengine.Context for testing.
Index ¶
- Constants
- type ComponentURL
- type Context
- func (c *Context) AppID() string
- func (c *Context) Call(service, method string, in, out appengine_internal.ProtoMessage, ...) error
- func (c *Context) Close()
- func (c *Context) Criticalf(format string, args ...interface{})
- func (c *Context) CurrentNamespace(namespace string)
- func (c *Context) CurrentUser() string
- func (c *Context) Debugf(format string, args ...interface{})
- func (c *Context) Errorf(format string, args ...interface{})
- func (c *Context) FullyQualifiedAppID() string
- func (c *Context) GetCurrentNamespace() string
- func (c *Context) Infof(format string, args ...interface{})
- func (c *Context) Login(u *user.User)
- func (c *Context) Logout()
- func (c *Context) Request() interface{}
- func (c *Context) Warningf(format string, args ...interface{})
- type ContextRecorder
- type LogLevel
- type ModuleConfig
- type Options
Examples ¶
Constants ¶
View Source
const AppServerFileName = "dev_appserver.py"
Dev app server script filename
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Context ¶
type Context struct {
// contains filtered or unexported fields
}
Context implements appengine.Context by running a dev_appserver.py process as a child and proxying all Context calls to the child. Use NewContext to create one.
func NewContext ¶
NewContext returns a new AppEngine context with an empty datastore, etc. A nil Options is valid and means to use the default values.
Example (Datastore) ¶
// Create mocked context. c, err := NewContext(nil) if err != nil { fmt.Println("initilizing context:", err) return } // Close the context when we are done. defer c.Close() // Get an element from the datastore. k := datastore.NewKey(c, "Entity", "stringID", 0, nil) e := "" if err := datastore.Get(c, k, &e); err != nil { fmt.Println("datastore get:", err) return } // Put an element in the datastore. if _, err := datastore.Put(c, k, &e); err != nil { fmt.Println("datastore put:", err) return }
Output:
Example (User) ¶
// Create mocked context. c, err := NewContext(nil) if err != nil { fmt.Println("initilizing context:", err) return } // Close the context when we are done. defer c.Close() // Log a user in. c.Login(&user.User{Email: "test@example.com", Admin: true}) // Get the user. u := user.Current(c) if u == nil { fmt.Println("we didn't get a user!") return } fmt.Println("Email:", u.Email) fmt.Println("Admin:", u.Admin)
Output: Email: test@example.com Admin: true
func (*Context) Call ¶
func (c *Context) Call(service, method string, in, out appengine_internal.ProtoMessage, opts *appengine_internal.CallOptions) error
func (*Context) Close ¶
func (c *Context) Close()
Close kills the child dev_appserver.py process, releasing its resources.
Close is not part of the appengine.Context interface.
func (*Context) CurrentNamespace ¶
func (*Context) CurrentUser ¶
func (*Context) FullyQualifiedAppID ¶
func (*Context) GetCurrentNamespace ¶
type ContextRecorder ¶
type ContextRecorder struct {
// contains filtered or unexported fields
}
func NewContextRecorder ¶
func NewContextRecorder(opts *Options) *ContextRecorder
func (*ContextRecorder) Context ¶
func (r *ContextRecorder) Context() *Context
type ModuleConfig ¶
Source Files ¶
Click to show internal directories.
Click to hide internal directories.