-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontext_testing.go
More file actions
42 lines (33 loc) · 887 Bytes
/
context_testing.go
File metadata and controls
42 lines (33 loc) · 887 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// Copyright 2012 GAEGo Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Copyright 2012 The Gorilla Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// +build !appengine
package context
import (
"net/http"
"appengine"
"github.com/icub3d/appenginetesting"
)
type Context appengine.Context
var cntx appengine.Context
// New returns a new testing context.
func NewContext(r *http.Request) appengine.Context {
if cntx == nil {
var err error
cntx, err = appenginetesting.NewContext(nil)
if err != nil {
panic(err)
}
}
return cntx
}
// Close closes a testing context registered when New() is called.
func Close() {
if cntx != nil {
cntx.(*appenginetesting.Context).Close()
cntx = nil
}
}