OLD | NEW |
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 Loading... |
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 Loading... |
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 } |
OLD | NEW |