| 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 dm | 5 package dm | 
| 6 | 6 | 
| 7 import ( | 7 import ( | 
| 8         "testing" | 8         "testing" | 
| 9 | 9 | 
| 10         "github.com/luci/gae/service/datastore" | 10         "github.com/luci/gae/service/datastore" | 
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 46                                 So(aid.SetDMEncoded("somethingfatsrnt"), ShouldE
     rrLike, "unable to parse") | 46                                 So(aid.SetDMEncoded("somethingfatsrnt"), ShouldE
     rrLike, "unable to parse") | 
| 47                                 So(aid.SetDMEncoded("something|cat"), ShouldErrL
     ike, `strconv.ParseUint: parsing "cat"`) | 47                                 So(aid.SetDMEncoded("something|cat"), ShouldErrL
     ike, `strconv.ParseUint: parsing "cat"`) | 
| 48                                 So(aid.SetDMEncoded(""), ShouldErrLike, "unable 
     to parse") | 48                                 So(aid.SetDMEncoded(""), ShouldErrLike, "unable 
     to parse") | 
| 49                                 So(aid.SetDMEncoded("somethingffffffff"), Should
     ErrLike, "unable to parse Attempt") | 49                                 So(aid.SetDMEncoded("somethingffffffff"), Should
     ErrLike, "unable to parse Attempt") | 
| 50                                 So(aid.FromProperty(datastore.MkPropertyNI(100))
     , ShouldErrLike, "wrong type") | 50                                 So(aid.FromProperty(datastore.MkPropertyNI(100))
     , ShouldErrLike, "wrong type") | 
| 51                         }) | 51                         }) | 
| 52 | 52 | 
| 53                 }) | 53                 }) | 
| 54         }) | 54         }) | 
| 55 } | 55 } | 
| 56 |  | 
| 57 func TestExecutionID(t *testing.T) { |  | 
| 58         t.Parallel() |  | 
| 59 |  | 
| 60         Convey("Test Execution_ID DM encoding", t, func() { |  | 
| 61                 Convey("render", func() { |  | 
| 62                         eid := NewExecutionID("", 0, 0) |  | 
| 63                         So(eid.DMEncoded(), ShouldEqual, "|ffffffff|ffffffff") |  | 
| 64 |  | 
| 65                         eid.Quest = "moo" |  | 
| 66                         So(eid.DMEncoded(), ShouldEqual, "moo|ffffffff|ffffffff"
     ) |  | 
| 67 |  | 
| 68                         eid.Id = 10 |  | 
| 69                         So(eid.DMEncoded(), ShouldEqual, "moo|ffffffff|fffffff5"
     ) |  | 
| 70 |  | 
| 71                         eid.Attempt = 1 |  | 
| 72                         So(eid.DMEncoded(), ShouldEqual, "moo|fffffffe|fffffff5"
     ) |  | 
| 73 |  | 
| 74                         p, err := eid.ToProperty() |  | 
| 75                         So(err, ShouldBeNil) |  | 
| 76                         So(p, ShouldResemble, datastore.MkPropertyNI("moo|ffffff
     fe|fffffff5")) |  | 
| 77                 }) |  | 
| 78 |  | 
| 79                 Convey("parse", func() { |  | 
| 80                         Convey("good", func() { |  | 
| 81                                 eid := &Execution_ID{} |  | 
| 82                                 So(eid.SetDMEncoded("something|fffffffe|fffffff5
     "), ShouldBeNil) |  | 
| 83                                 So(eid, ShouldResemble, NewExecutionID("somethin
     g", 1, 10)) |  | 
| 84 |  | 
| 85                                 So(eid.FromProperty(datastore.MkPropertyNI("wat|
     ffffffff|fffffffa")), ShouldBeNil) |  | 
| 86                                 So(eid, ShouldResemble, NewExecutionID("wat", 0,
      5)) |  | 
| 87                         }) |  | 
| 88 |  | 
| 89                         Convey("err", func() { |  | 
| 90                                 eid := &Execution_ID{} |  | 
| 91                                 So(eid.SetDMEncoded("somethingfatsrnt"), ShouldE
     rrLike, "unable to parse") |  | 
| 92                                 So(eid.SetDMEncoded("something|cat|ffffffff|bob"
     ), ShouldErrLike, `strconv.ParseUint: parsing "cat"`) |  | 
| 93                                 So(eid.SetDMEncoded("something|cat|ffffffff"), S
     houldErrLike, `strconv.ParseUint: parsing "cat"`) |  | 
| 94                                 So(eid.SetDMEncoded("something|ffffffff|cat"), S
     houldErrLike, `strconv.ParseUint: parsing "cat"`) |  | 
| 95                                 So(eid.SetDMEncoded(""), ShouldErrLike, "unable 
     to parse") |  | 
| 96                                 So(eid.SetDMEncoded("somethingffffffff"), Should
     ErrLike, "unable to parse") |  | 
| 97                                 So(eid.FromProperty(datastore.MkPropertyNI(100))
     , ShouldErrLike, "wrong type") |  | 
| 98                         }) |  | 
| 99 |  | 
| 100                 }) |  | 
| 101         }) |  | 
| 102 } |  | 
| OLD | NEW | 
|---|