| 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 pubsub | 5 package pubsub |
| 6 | 6 |
| 7 import ( | 7 import ( |
| 8 "bytes" | 8 "bytes" |
| 9 "compress/zlib" | 9 "compress/zlib" |
| 10 "errors" | 10 "errors" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 | 28 |
| 29 type testTopic struct { | 29 type testTopic struct { |
| 30 sync.Mutex | 30 sync.Mutex |
| 31 | 31 |
| 32 err error | 32 err error |
| 33 | 33 |
| 34 msgC chan *pubsub.Message | 34 msgC chan *pubsub.Message |
| 35 nextMessageID int | 35 nextMessageID int |
| 36 } | 36 } |
| 37 | 37 |
| 38 func (t *testTopic) Name() string { return "test" } | 38 func (t *testTopic) String() string { return "test" } |
| 39 | 39 |
| 40 func (t *testTopic) Publish(c context.Context, msgs ...*pubsub.Message) ([]strin
g, error) { | 40 func (t *testTopic) Publish(c context.Context, msgs ...*pubsub.Message) ([]strin
g, error) { |
| 41 if t.err != nil { | 41 if t.err != nil { |
| 42 return nil, t.err | 42 return nil, t.err |
| 43 } | 43 } |
| 44 | 44 |
| 45 ids := make([]string, len(msgs)) | 45 ids := make([]string, len(msgs)) |
| 46 for i, m := range msgs { | 46 for i, m := range msgs { |
| 47 t.msgC <- m | 47 t.msgC <- m |
| 48 ids[i] = t.getNextMessageID() | 48 ids[i] = t.getNextMessageID() |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 So(st.DiscardedMessages(), ShouldEqual, 0) | 141 So(st.DiscardedMessages(), ShouldEqual, 0) |
| 142 }) | 142 }) |
| 143 }) | 143 }) |
| 144 | 144 |
| 145 Convey(`Will return an error if Publish failed.`, func() { | 145 Convey(`Will return an error if Publish failed.`, func() { |
| 146 tt.err = errors.New("test: error") | 146 tt.err = errors.New("test: error") |
| 147 So(o.SendBundle(bundle), ShouldNotBeNil) | 147 So(o.SendBundle(bundle), ShouldNotBeNil) |
| 148 }) | 148 }) |
| 149 }) | 149 }) |
| 150 } | 150 } |
| OLD | NEW |