From 4c6ce9e090af74dd0878a7ccc703b17229bab67a Mon Sep 17 00:00:00 2001 From: tmdiep Date: Wed, 2 Dec 2020 04:02:10 -0500 Subject: [PATCH] Minor unit test update --- pubsublite/ps/publisher_test.go | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/pubsublite/ps/publisher_test.go b/pubsublite/ps/publisher_test.go index dab70fd312a..19e467580be 100644 --- a/pubsublite/ps/publisher_test.go +++ b/pubsublite/ps/publisher_test.go @@ -32,13 +32,14 @@ import ( // call. type mockWirePublisher struct { Verifier *test.RPCVerifier - FakeErr error Stopped bool + err error } func (mp *mockWirePublisher) Publish(msg *pb.PubSubMessage, onResult wire.PublishResultFunc) { resp, err := mp.Verifier.Pop(msg) if err != nil { + mp.err = err onResult(nil, err) return } @@ -48,9 +49,9 @@ func (mp *mockWirePublisher) Publish(msg *pb.PubSubMessage, onResult wire.Publis func (mp *mockWirePublisher) Start() {} func (mp *mockWirePublisher) Stop() { mp.Stopped = true } -func (mp *mockWirePublisher) WaitStarted() error { return mp.FakeErr } -func (mp *mockWirePublisher) WaitStopped() error { return mp.FakeErr } -func (mp *mockWirePublisher) Error() error { return mp.FakeErr } +func (mp *mockWirePublisher) WaitStarted() error { return mp.err } +func (mp *mockWirePublisher) WaitStopped() error { return mp.err } +func (mp *mockWirePublisher) Error() error { return mp.err } func newTestPublisherClient(verifier *test.RPCVerifier, settings PublishSettings) *PublisherClient { return &PublisherClient{ @@ -220,6 +221,12 @@ func TestPublisherClientTranslatePublishResultErrors(t *testing.T) { if !test.ErrorEqual(gotErr, tc.wantErr) { t.Errorf("Publish() got err: (%v), want err: (%v)", gotErr, tc.wantErr) } + if !test.ErrorEqual(pubClient.Error(), tc.wireErr) { + t.Errorf("PublisherClient.Error() got: (%v), want: (%v)", pubClient.Error(), tc.wireErr) + } + if got, want := pubClient.wirePub.(*mockWirePublisher).Stopped, false; got != want { + t.Errorf("Publisher.Stopped: got %v, want %v", got, want) + } }) } }