-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathuser_test.go
More file actions
43 lines (34 loc) · 799 Bytes
/
user_test.go
File metadata and controls
43 lines (34 loc) · 799 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
43
// Copyright 2012 The AEGo Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package user
import (
"appengine/datastore"
"github.com/gaego/context"
//"github.com/gaego/ds"
"testing"
)
func setUp() {}
func tearDown() {
context.Close()
}
func TestGet(t *testing.T) {
c := context.NewContext(nil)
defer tearDown()
// Save it.
u := New()
u.Email = "test@example.com"
u.Key = datastore.NewKey(c, "User", "", 0, nil)
err := u.Put(c)
if err != nil {
t.Errorf(`err: %q, want nil`, err)
}
// Get it.
u2, err := Get(c, u.Key.StringID())
if err != nil {
t.Errorf(`err: %v, want nil`, err)
}
if u2.Email != "test@example.com" {
t.Errorf(`u2.Email: %v, want "test@example.com"`, u2.Email)
}
}