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

Side by Side Diff: dm/appengine/mutate/schedule_execution_test.go

Issue 2951393002: [errors] de-specialize Transient in favor of Tags. (Closed)
Patch Set: more refactor Created 3 years, 5 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
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 mutate 5 package mutate
6 6
7 import ( 7 import (
8 "fmt" 8 "fmt"
9 "testing" 9 "testing"
10 "time" 10 "time"
11 11
12 ds "github.com/luci/gae/service/datastore" 12 ds "github.com/luci/gae/service/datastore"
13 "github.com/luci/luci-go/common/errors" 13 "github.com/luci/luci-go/common/errors"
14 "github.com/luci/luci-go/common/proto/google" 14 "github.com/luci/luci-go/common/proto/google"
15 "github.com/luci/luci-go/common/retry/transient"
15 "github.com/luci/luci-go/dm/api/service/v1" 16 "github.com/luci/luci-go/dm/api/service/v1"
16 "github.com/luci/luci-go/dm/appengine/distributor/fake" 17 "github.com/luci/luci-go/dm/appengine/distributor/fake"
17 "github.com/luci/luci-go/dm/appengine/model" 18 "github.com/luci/luci-go/dm/appengine/model"
18 19
19 . "github.com/luci/luci-go/common/testing/assertions" 20 . "github.com/luci/luci-go/common/testing/assertions"
20 . "github.com/smartystreets/goconvey/convey" 21 . "github.com/smartystreets/goconvey/convey"
21 ) 22 )
22 23
23 func TestScheduleExecution(t *testing.T) { 24 func TestScheduleExecution(t *testing.T) {
24 t.Parallel() 25 t.Parallel()
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 ex, err := ds.Exists(c, ds.MakeKey(c, 65 ex, err := ds.Exists(c, ds.MakeKey(c,
65 "Attempt", a.ID.DMEncoded(), 66 "Attempt", a.ID.DMEncoded(),
66 "Execution", 1, 67 "Execution", 1,
67 "tumble.Mutation", "n:timeout")) 68 "tumble.Mutation", "n:timeout"))
68 So(err, ShouldBeNil) 69 So(err, ShouldBeNil)
69 So(ex.All(), ShouldBeTrue) 70 So(ex.All(), ShouldBeTrue)
70 }) 71 })
71 }) 72 })
72 73
73 Convey("transient", func() { 74 Convey("transient", func() {
74 » » » » dist.RunError = errors.WrapTransient(errors.New( "transient failure")) 75 » » » » dist.RunError = errors.New("transient failure", transient.Tag)
75 76
76 muts, err := se.RollForward(c) 77 muts, err := se.RollForward(c)
77 So(err, ShouldErrLike, "transient") 78 So(err, ShouldErrLike, "transient")
78 So(muts, ShouldBeNil) 79 So(muts, ShouldBeNil)
79 }) 80 })
80 81
81 Convey("rejection", func() { 82 Convey("rejection", func() {
82 dist.RunError = errors.New("no soup for you") 83 dist.RunError = errors.New("no soup for you")
83 84
84 muts, err := se.RollForward(c) 85 muts, err := se.RollForward(c)
85 So(err, ShouldBeNil) 86 So(err, ShouldBeNil)
86 So(muts, ShouldBeNil) 87 So(muts, ShouldBeNil)
87 88
88 So(ds.Get(c, a, e), ShouldBeNil) 89 So(ds.Get(c, a, e), ShouldBeNil)
89 So(a.State, ShouldEqual, dm.Attempt_ABNORMAL_FIN ISHED) 90 So(a.State, ShouldEqual, dm.Attempt_ABNORMAL_FIN ISHED)
90 So(a.Result.AbnormalFinish.Status, ShouldEqual, dm.AbnormalFinish_REJECTED) 91 So(a.Result.AbnormalFinish.Status, ShouldEqual, dm.AbnormalFinish_REJECTED)
91 So(a.Result.AbnormalFinish.Reason, ShouldContain Substring, "non-transient") 92 So(a.Result.AbnormalFinish.Reason, ShouldContain Substring, "non-transient")
92 93
93 So(e.State, ShouldEqual, dm.Execution_ABNORMAL_F INISHED) 94 So(e.State, ShouldEqual, dm.Execution_ABNORMAL_F INISHED)
94 So(e.Result.AbnormalFinish.Status, ShouldEqual, dm.AbnormalFinish_REJECTED) 95 So(e.Result.AbnormalFinish.Status, ShouldEqual, dm.AbnormalFinish_REJECTED)
95 So(e.Result.AbnormalFinish.Reason, ShouldContain Substring, "non-transient") 96 So(e.Result.AbnormalFinish.Reason, ShouldContain Substring, "non-transient")
96 }) 97 })
97 98
98 }) 99 })
99 }) 100 })
100 } 101 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698