| 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 mutate | 5 package mutate |
| 6 | 6 |
| 7 import ( | 7 import ( |
| 8 "testing" | 8 "testing" |
| 9 | 9 |
| 10 "github.com/luci/gae/filter/featureBreaker" | 10 "github.com/luci/gae/filter/featureBreaker" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 }) | 29 }) |
| 30 | 30 |
| 31 Convey("RollForward", func() { | 31 Convey("RollForward", func() { |
| 32 a := &model.Attempt{ID: *ea.ID} | 32 a := &model.Attempt{ID: *ea.ID} |
| 33 | 33 |
| 34 Convey("Good", func() { | 34 Convey("Good", func() { |
| 35 So(datastore.Get(c).Get(a), ShouldEqual, datasto
re.ErrNoSuchEntity) | 35 So(datastore.Get(c).Get(a), ShouldEqual, datasto
re.ErrNoSuchEntity) |
| 36 | 36 |
| 37 muts, err := ea.RollForward(c) | 37 muts, err := ea.RollForward(c) |
| 38 So(err, ShouldBeNil) | 38 So(err, ShouldBeNil) |
| 39 » » » » So(muts, ShouldBeEmpty) | 39 » » » » So(muts, ShouldHaveLength, 1) |
| 40 | 40 |
| 41 ds := datastore.Get(c) | 41 ds := datastore.Get(c) |
| 42 So(ds.Get(a), ShouldEqual, nil) | 42 So(ds.Get(a), ShouldEqual, nil) |
| 43 » » » » So(a.State, ShouldEqual, dm.Attempt_NEEDS_EXECUT
ION) | 43 » » » » So(a.State, ShouldEqual, dm.Attempt_SCHEDULING) |
| 44 | 44 |
| 45 Convey("replaying the mutation after the state h
as evolved is a noop", func() { | 45 Convey("replaying the mutation after the state h
as evolved is a noop", func() { |
| 46 » » » » » a.State.MustEvolve(dm.Attempt_EXECUTING) | 46 » » » » » So(a.ModifyState(c, dm.Attempt_EXECUTING
), ShouldBeNil) |
| 47 So(ds.Put(a), ShouldBeNil) | 47 So(ds.Put(a), ShouldBeNil) |
| 48 | 48 |
| 49 muts, err = ea.RollForward(c) | 49 muts, err = ea.RollForward(c) |
| 50 So(err, ShouldBeNil) | 50 So(err, ShouldBeNil) |
| 51 So(muts, ShouldBeEmpty) | 51 So(muts, ShouldBeEmpty) |
| 52 | 52 |
| 53 So(ds.Get(a), ShouldEqual, nil) | 53 So(ds.Get(a), ShouldEqual, nil) |
| 54 So(a.State, ShouldEqual, dm.Attempt_EXEC
UTING) | 54 So(a.State, ShouldEqual, dm.Attempt_EXEC
UTING) |
| 55 }) | 55 }) |
| 56 }) | 56 }) |
| 57 | 57 |
| 58 Convey("Bad", func() { | 58 Convey("Bad", func() { |
| 59 c, fb := featureBreaker.FilterRDS(c, nil) | 59 c, fb := featureBreaker.FilterRDS(c, nil) |
| 60 fb.BreakFeatures(nil, "GetMulti") | 60 fb.BreakFeatures(nil, "GetMulti") |
| 61 | 61 |
| 62 muts, err := ea.RollForward(c) | 62 muts, err := ea.RollForward(c) |
| 63 So(err, ShouldErrLike, `feature "GetMulti" is br
oken`) | 63 So(err, ShouldErrLike, `feature "GetMulti" is br
oken`) |
| 64 So(muts, ShouldBeEmpty) | 64 So(muts, ShouldBeEmpty) |
| 65 | 65 |
| 66 fb.UnbreakFeatures("GetMulti") | 66 fb.UnbreakFeatures("GetMulti") |
| 67 | 67 |
| 68 So(datastore.Get(c).Get(a), ShouldEqual, datasto
re.ErrNoSuchEntity) | 68 So(datastore.Get(c).Get(a), ShouldEqual, datasto
re.ErrNoSuchEntity) |
| 69 }) | 69 }) |
| 70 }) | 70 }) |
| 71 }) | 71 }) |
| 72 } | 72 } |
| OLD | NEW |