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

Side by Side Diff: service/datastore/serialize/serialize_test.go

Issue 1345043005: Fix zero time bug (Closed) Base URL: https://github.com/luci/gae.git@master
Patch Set: 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/serialize/serialize.go ('k') | no next file » | 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 package serialize 5 package serialize
6 6
7 import ( 7 import (
8 "bytes" 8 "bytes"
9 "fmt" 9 "fmt"
10 "io" 10 "io"
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 Convey("Time", func() { 183 Convey("Time", func() {
184 tp := mp(time.Now().UTC()) 184 tp := mp(time.Now().UTC())
185 So(string(ToBytes(tp.Value())), ShouldEqual, string(ToBy tes(tp)[1:])) 185 So(string(ToBytes(tp.Value())), ShouldEqual, string(ToBy tes(tp)[1:]))
186 }) 186 })
187 187
188 Convey("Zero time", func() { 188 Convey("Zero time", func() {
189 buf := mkBuf(nil) 189 buf := mkBuf(nil)
190 So(WriteTime(buf, time.Time{}), ShouldBeNil) 190 So(WriteTime(buf, time.Time{}), ShouldBeNil)
191 t, err := ReadTime(mkBuf(buf.Bytes())) 191 t, err := ReadTime(mkBuf(buf.Bytes()))
192 So(err, ShouldBeNil) 192 So(err, ShouldBeNil)
193 » » » So(t.IsZero(), ShouldBeTrue) 193 » » » So(t, ShouldResemble, time.Time{})
194 }) 194 })
195 195
196 Convey("Bad ToBytes", func() { 196 Convey("Bad ToBytes", func() {
197 So(func() { ToBytes(100.7) }, ShouldPanic) 197 So(func() { ToBytes(100.7) }, ShouldPanic)
198 So(func() { ToBytesWithContext(100.7) }, ShouldPanic) 198 So(func() { ToBytesWithContext(100.7) }, ShouldPanic)
199 }) 199 })
200 200
201 Convey("ReadKey", func() { 201 Convey("ReadKey", func() {
202 Convey("good cases", func() { 202 Convey("good cases", func() {
203 Convey("w/ ctx decodes normally w/ ctx", func() { 203 Convey("w/ ctx decodes normally w/ ctx", func() {
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
465 for i := 0; i < MaxIndexColumns+1; i++ { 465 for i := 0; i < MaxIndexColumns+1; i++ {
466 id.SortBy = append(id.SortBy, ds.IndexCo lumn{Property: "Hi", Descending: true}) 466 id.SortBy = append(id.SortBy, ds.IndexCo lumn{Property: "Hi", Descending: true})
467 } 467 }
468 data := ToBytes(*id.PrepForIdxTable()) 468 data := ToBytes(*id.PrepForIdxTable())
469 newID, err = ReadIndexDefinition(mkBuf(data)) 469 newID, err = ReadIndexDefinition(mkBuf(data))
470 So(err, ShouldErrLike, "over 64 sort orders") 470 So(err, ShouldErrLike, "over 64 sort orders")
471 }) 471 })
472 }) 472 })
473 }) 473 })
474 } 474 }
OLDNEW
« no previous file with comments | « service/datastore/serialize/serialize.go ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698