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

Side by Side Diff: service/datastore/index_test.go

Issue 1355783002: Refactor keys and queries in datastore service and implementation. (Closed) Base URL: https://github.com/luci/gae.git@master
Patch Set: appease errcheck Created 5 years, 3 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
« no previous file with comments | « service/datastore/index.go ('k') | service/datastore/interface.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 // adapted from github.com/golang/appengine/datastore 5 // adapted from github.com/golang/appengine/datastore
6 6
7 package datastore 7 package datastore
8 8
9 import ( 9 import (
10 "testing" 10 "testing"
11 11
12 . "github.com/smartystreets/goconvey/convey" 12 . "github.com/smartystreets/goconvey/convey"
13 ) 13 )
14 14
15 func TestIndexDefinition(t *testing.T) { 15 func TestIndexDefinition(t *testing.T) {
16 t.Parallel() 16 t.Parallel()
17 17
18 Convey("Test IndexDefinition", t, func() { 18 Convey("Test IndexDefinition", t, func() {
19 Convey("basic", func() { 19 Convey("basic", func() {
20 id := IndexDefinition{Kind: "kind"} 20 id := IndexDefinition{Kind: "kind"}
21 21
22 So(id.Builtin(), ShouldBeTrue) 22 So(id.Builtin(), ShouldBeTrue)
23 So(id.Compound(), ShouldBeFalse) 23 So(id.Compound(), ShouldBeFalse)
24 So(id.String(), ShouldEqual, "B:kind") 24 So(id.String(), ShouldEqual, "B:kind")
25 25
26 id.SortBy = append(id.SortBy, IndexColumn{Property: "pro p"}) 26 id.SortBy = append(id.SortBy, IndexColumn{Property: "pro p"})
27 » » » So(id.SortBy[0].Direction, ShouldEqual, ASCENDING) 27 » » » So(id.SortBy[0].Descending, ShouldBeFalse)
28 So(id.Builtin(), ShouldBeTrue) 28 So(id.Builtin(), ShouldBeTrue)
29 So(id.Compound(), ShouldBeFalse) 29 So(id.Compound(), ShouldBeFalse)
30 So(id.String(), ShouldEqual, "B:kind/prop") 30 So(id.String(), ShouldEqual, "B:kind/prop")
31 31
32 » » » id.SortBy = append(id.SortBy, IndexColumn{"other", DESCE NDING}) 32 » » » id.SortBy = append(id.SortBy, IndexColumn{Property: "oth er", Descending: true})
33 id.Ancestor = true 33 id.Ancestor = true
34 So(id.Builtin(), ShouldBeFalse) 34 So(id.Builtin(), ShouldBeFalse)
35 So(id.Compound(), ShouldBeTrue) 35 So(id.Compound(), ShouldBeTrue)
36 So(id.String(), ShouldEqual, "C:kind|A/prop/-other") 36 So(id.String(), ShouldEqual, "C:kind|A/prop/-other")
37 37
38 // invalid 38 // invalid
39 » » » id.SortBy = append(id.SortBy, IndexColumn{"", DESCENDING }) 39 » » » id.SortBy = append(id.SortBy, IndexColumn{Property: "", Descending: true})
40 So(id.Builtin(), ShouldBeFalse) 40 So(id.Builtin(), ShouldBeFalse)
41 So(id.Compound(), ShouldBeFalse) 41 So(id.Compound(), ShouldBeFalse)
42 }) 42 })
43 }) 43 })
44 } 44 }
OLDNEW
« no previous file with comments | « service/datastore/index.go ('k') | service/datastore/interface.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698