| Index: milo/common/pubsub_test.go
|
| diff --git a/milo/common/pubsub_test.go b/milo/common/pubsub_test.go
|
| index 4ac7886d91ec9ec43f73b9a5b5c37aa7bc3648ff..1c88968346c6acf23b37656803494f98025a5904 100644
|
| --- a/milo/common/pubsub_test.go
|
| +++ b/milo/common/pubsub_test.go
|
| @@ -61,53 +61,62 @@ func TestPubSub(t *testing.T) {
|
| Convey("Test Environment", t, func() {
|
| c := memory.UseWithAppID(context.Background(), "dev~luci-milo")
|
| c = gologger.StdConfig.Use(c)
|
| - client := &testPubSubClient{
|
| + miloClient := &testPubSubClient{
|
| topics: map[string]error{},
|
| subscriptions: map[string]error{},
|
| createdSubsErr: map[string]error{},
|
| createdSubs: map[string]pubsub.SubscriptionConfig{}}
|
| - c = context.WithValue(c, &pubSubClientKey, client)
|
| + bbClient := &testPubSubClient{
|
| + topics: map[string]error{},
|
| + subscriptions: map[string]error{},
|
| + createdSubsErr: map[string]error{},
|
| + createdSubs: map[string]pubsub.SubscriptionConfig{}}
|
| + clients := pubsubClients{}
|
| + clients["buildbucket"] = bbClient
|
| + clients["luci-milo"] = miloClient
|
| + c = context.WithValue(c, &pubSubClientKey, clients)
|
|
|
| Convey("Buildbucket PubSub subscriber", func() {
|
| - proj := "foo"
|
| + proj := "buildbucket"
|
| Convey("Non-existant topic", func() {
|
| - client.topics["builds"] = errNotExist
|
| + bbClient.topics["builds"] = errNotExist
|
| err := ensureBuildbucketSubscribed(c, proj)
|
| So(err.Error(), ShouldEndWith, "does not exist")
|
| })
|
| Convey("Permission denied", func() {
|
| pErr := errors.New(
|
| "something PermissionDenied something")
|
| - client.topics["builds"] = pErr
|
| + bbClient.topics["builds"] = pErr
|
| err := ensureBuildbucketSubscribed(c, proj)
|
| So(err, ShouldEqual, pErr)
|
| })
|
| Convey("Normal error", func() {
|
| pErr := errors.New("foobar")
|
| - client.topics["builds"] = pErr
|
| + bbClient.topics["builds"] = pErr
|
| err := ensureBuildbucketSubscribed(c, proj)
|
| So(err, ShouldEqual, pErr)
|
| })
|
| - client.topics["builds"] = nil
|
| + bbClient.topics["builds"] = nil
|
| Convey("Subscription exists", func() {
|
| - client.subscriptions["luci-milo"] = nil
|
| + miloClient.subscriptions["buildbucket"] = nil
|
| err := ensureBuildbucketSubscribed(c, proj)
|
| So(err, ShouldBeNil)
|
| - So(len(client.createdSubs), ShouldEqual, 0)
|
| + So(len(miloClient.createdSubs), ShouldEqual, 0)
|
| + So(len(bbClient.createdSubs), ShouldEqual, 0)
|
| })
|
| - client.subscriptions["luci-milo"] = errNotExist
|
| + miloClient.subscriptions["buildbucket"] = errNotExist
|
| Convey("Not registered", func() {
|
| errNotReg := errors.New("The supplied HTTP URL is not registered")
|
| - client.createdSubsErr["luci-milo"] = errNotReg
|
| + miloClient.createdSubsErr["buildbucket"] = errNotReg
|
| err := ensureBuildbucketSubscribed(c, proj)
|
| So(err, ShouldEqual, errNotReg)
|
| })
|
| Convey("Create subscription", func() {
|
| - client.createdSubsErr["luci-milo"] = nil
|
| + miloClient.createdSubsErr["buildbucket"] = nil
|
| err := ensureBuildbucketSubscribed(c, proj)
|
| So(err, ShouldBeNil)
|
| - So(len(client.createdSubs), ShouldEqual, 1)
|
| - _, ok := client.createdSubs["luci-milo"]
|
| + So(len(miloClient.createdSubs), ShouldEqual, 1)
|
| + _, ok := miloClient.createdSubs["buildbucket"]
|
| So(ok, ShouldEqual, true)
|
| })
|
| })
|
|
|