Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(671)

Side by Side Diff: go/src/infra/gae/libs/meta/eg_test.go

Issue 1152383003: Simple memory testing for gae/wrapper (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@better_context_lite
Patch Set: fix capitalization Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 package meta
6
7 import (
8 "testing"
9
10 "golang.org/x/net/context"
11
12 "infra/gae/libs/wrapper"
13 "infra/gae/libs/wrapper/memory"
14
15 . "github.com/smartystreets/goconvey/convey"
16 )
17
18 func TestGetEntityGroupVersion(t *testing.T) {
M-A Ruel 2015/05/27 20:14:47 Why none of your tests are t.Parallel()?
iannucci 2015/05/27 21:36:22 because the entire test suite takes .1 seconds and
M-A Ruel 2015/05/28 22:42:38 There's two reasons; - With Convey(), you make lar
iannucci 2015/05/28 23:00:34 Oh, that reminds me. I have half of a patch to con
19 Convey("GetEntityGroupVersion", t, func() {
20 c := memory.Use(memory.Enable(context.Background()))
21 ds := wrapper.GetDS(c)
22
23 type A struct {
M-A Ruel 2015/05/27 20:14:47 a := &struct { ... }{Val:10} would work fine. You
iannucci 2015/05/27 21:36:22 Put uses reflection to discover the type name. An
24 ID int64 `datastore:"-" goon:"id"`
25 Val int
26 }
27
28 a := &A{Val: 10}
29 aKey, err := ds.Put(a)
30 So(err, ShouldBeNil)
31
32 v, err := GetEntityGroupVersion(c, aKey)
33 So(err, ShouldBeNil)
34 So(v, ShouldEqual, 1)
35
36 So(ds.Delete(aKey), ShouldBeNil)
37
38 v, err = GetEntityGroupVersion(c, ds.NewKey("madeUp", "thing", 0 , aKey))
39 So(err, ShouldBeNil)
40 So(v, ShouldEqual, 2)
41
42 v, err = GetEntityGroupVersion(c, ds.NewKey("madeUp", "thing", 0 , nil))
43 So(err, ShouldBeNil)
44 So(v, ShouldEqual, 0)
45
46 tDs := ds.(wrapper.Testable)
47 tDs.BreakFeatures(nil, "Get")
48
49 v, err = GetEntityGroupVersion(c, aKey)
50 So(err.Error(), ShouldContainSubstring, "INTERNAL_ERROR")
51 })
52 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698