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

Side by Side Diff: common/errors/multierror_test.go

Issue 1863973002: LogDog: Update to archival V2. (Closed) Base URL: https://github.com/luci/luci-go@grpcutil-errors
Patch Set: Code review comments, use Pub/Sub, archival staging, quality of life. Created 4 years, 8 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 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 errors 5 package errors
6 6
7 import ( 7 import (
8 "errors" 8 "errors"
9 "fmt"
9 "testing" 10 "testing"
10 11
11 . "github.com/smartystreets/goconvey/convey" 12 . "github.com/smartystreets/goconvey/convey"
12 ) 13 )
13 14
14 type otherMEType []error 15 type otherMEType []error
15 16
16 func (o otherMEType) Error() string { return "FAIL" } 17 func (o otherMEType) Error() string { return "FAIL" }
17 18
18 func TestUpstreamErrors(t *testing.T) { 19 func TestUpstreamErrors(t *testing.T) {
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 Convey("Test MultiError Conversion", t, func() { 53 Convey("Test MultiError Conversion", t, func() {
53 ome := otherMEType{errors.New("sup")} 54 ome := otherMEType{errors.New("sup")}
54 So(Fix(ome), ShouldHaveSameTypeAs, MultiError{}) 55 So(Fix(ome), ShouldHaveSameTypeAs, MultiError{})
55 }) 56 })
56 57
57 Convey("Fix passes through", t, func() { 58 Convey("Fix passes through", t, func() {
58 e := errors.New("unique") 59 e := errors.New("unique")
59 So(Fix(e), ShouldEqual, e) 60 So(Fix(e), ShouldEqual, e)
60 }) 61 })
61 } 62 }
63
64 func TestAny(t *testing.T) {
65 t.Parallel()
66
67 Convey(`Testing the Any function`, t, func() {
68 for _, tc := range []struct {
69 err error
70 has bool
71 }{
72 {nil, false},
73 {New("test error"), true},
74 {New("other error"), false},
75 {MultiError{MultiError{New("test error"), nil}, New("oth er error")}, true},
76 } {
77 Convey(fmt.Sprintf(`Registers %v for error [%v]`, tc.has , tc.err), func() {
78 So(Any(tc.err, func(err error) bool { return err .Error() == "test error" }), ShouldEqual, tc.has)
79 })
80 }
81 })
82 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698