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

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

Issue 2007123002: datastore: Update AllocateIDs to take keys. (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/gae@master
Patch Set: Rebase, comments. Created 4 years, 6 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/key.go ('k') | service/datastore/multiarg.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 LUCI Authors. All rights reserved. 1 // Copyright 2015 The LUCI Authors. All rights reserved.
2 // Use of this source code is governed under the Apache License, Version 2.0 2 // Use of this source code is governed under the Apache License, Version 2.0
3 // that can be found in the LICENSE file. 3 // that can be found in the LICENSE file.
4 4
5 package datastore 5 package datastore
6 6
7 import ( 7 import (
8 "encoding/json" 8 "encoding/json"
9 "fmt" 9 "fmt"
10 "testing" 10 "testing"
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 So(err, ShouldErrLike, "bad JSON key") 98 So(err, ShouldErrLike, "bad JSON key")
99 }) 99 })
100 }) 100 })
101 } 101 }
102 102
103 func TestKeyValidity(t *testing.T) { 103 func TestKeyValidity(t *testing.T) {
104 //t.Parallel() 104 //t.Parallel()
105 105
106 Convey("keys validity", t, func() { 106 Convey("keys validity", t, func() {
107 Convey("incomplete", func() { 107 Convey("incomplete", func() {
108 » » » So(MakeKey("aid", "ns", "kind", 1).Incomplete(), ShouldB eFalse) 108 » » » So(MakeKey("aid", "ns", "kind", 1).IsIncomplete(), Shoul dBeFalse)
109 » » » So(MakeKey("aid", "ns", "kind", 0).Incomplete(), ShouldB eTrue) 109 » » » So(MakeKey("aid", "ns", "kind", 0).IsIncomplete(), Shoul dBeTrue)
110 }) 110 })
111 111
112 Convey("invalid", func() { 112 Convey("invalid", func() {
113 So(MakeKey("aid", "ns", "hat", "face", "__kind__", 1).Va lid(true, "aid", "ns"), ShouldBeTrue) 113 So(MakeKey("aid", "ns", "hat", "face", "__kind__", 1).Va lid(true, "aid", "ns"), ShouldBeTrue)
114 114
115 bads := []*Key{ 115 bads := []*Key{
116 NewKeyToks("aid", "ns", []KeyTok{{"Kind", 1, "1" }}), 116 NewKeyToks("aid", "ns", []KeyTok{{"Kind", 1, "1" }}),
117 MakeKey("", "ns", "hat", "face"), 117 MakeKey("", "ns", "hat", "face"),
118 MakeKey("aid", "ns", "base", 1, "", "id"), 118 MakeKey("aid", "ns", "base", 1, "", "id"),
119 MakeKey("aid", "ns", "hat", "face", "__kind__", 1), 119 MakeKey("aid", "ns", "hat", "face", "__kind__", 1),
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 } 240 }
241 241
242 for i := 1; i < len(s); i++ { 242 for i := 1; i < len(s); i++ {
243 So(s[i-1], shouldBeLess, s[i]) 243 So(s[i-1], shouldBeLess, s[i])
244 So(s[i-1], shouldNotBeEqual, s[i]) 244 So(s[i-1], shouldNotBeEqual, s[i])
245 So(s[i], shouldNotBeEqual, s[i-1]) 245 So(s[i], shouldNotBeEqual, s[i-1])
246 So(s[i], shouldNotBeLess, s[i-1]) 246 So(s[i], shouldNotBeLess, s[i-1])
247 } 247 }
248 }) 248 })
249 } 249 }
OLDNEW
« no previous file with comments | « service/datastore/key.go ('k') | service/datastore/multiarg.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698