Skip to content

Commit

Permalink
Errorf--> Error appropriate change
Browse files Browse the repository at this point in the history
Signed-off-by: sadath-12 <[email protected]>
  • Loading branch information
sadath-12 committed Dec 23, 2023
1 parent 38bc154 commit 35c37bc
Showing 1 changed file with 22 additions and 22 deletions.
44 changes: 22 additions & 22 deletions service/grpc/topic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,29 +29,29 @@ import (
func TestTopicErrors(t *testing.T) {
server := getTestServer()
err := server.AddTopicEventHandler(nil, nil)
require.Errorf(t, err, "expected error on nil sub with AddTopicEventHandler")
require.Error(t, err, "expected error on nil sub with AddTopicEventHandler")

err = server.AddBulkTopicEventHandler(nil, nil, 0, 0)
require.Errorf(t, err, "expected error on nil sub with AddBulkTopicEventHandler")
require.Error(t, err, "expected error on nil sub with AddBulkTopicEventHandler")

sub := &common.Subscription{}
err = server.AddTopicEventHandler(sub, nil)
require.Errorf(t, err, "expected error on invalid sub with AddTopicEventHandler")
require.Error(t, err, "expected error on invalid sub with AddTopicEventHandler")
err = server.AddBulkTopicEventHandler(sub, nil, 0, 0)
require.Errorf(t, err, "expected error on invalid sub with AddBulkTopicEventHandler")
require.Error(t, err, "expected error on invalid sub with AddBulkTopicEventHandler")

sub.PubsubName = "messages"
err = server.AddTopicEventHandler(sub, nil)
require.Errorf(t, err, "expected error on sub without topic with AddTopicEventHandler")
require.Error(t, err, "expected error on sub without topic with AddTopicEventHandler")
sub.PubsubName = "messages"
err = server.AddBulkTopicEventHandler(sub, nil, 0, 0)
require.Errorf(t, err, "expected error on sub without topic with AddBulkTopicEventHandler")
require.Error(t, err, "expected error on sub without topic with AddBulkTopicEventHandler")

sub.Topic = "test"
err = server.AddTopicEventHandler(sub, nil)
require.Errorf(t, err, "expected error on sub without handler")
require.Error(t, err, "expected error on sub without handler")
err = server.AddBulkTopicEventHandler(sub, nil, 0, 0)
require.Errorf(t, err, "expected error on sub without handler")
require.Error(t, err, "expected error on sub without handler")
}

func TestTopicSubscriptionList(t *testing.T) {
Expand All @@ -64,7 +64,7 @@ func TestTopicSubscriptionList(t *testing.T) {
Route: "/test",
}
err := server.AddTopicEventHandler(sub1, eventHandler)
assert.Nil(t, err)
require.NoError(t, err)
resp, err := server.ListTopicSubscriptions(context.Background(), &empty.Empty{})
require.NoError(t, err)
assert.NotNil(t, resp)
Expand All @@ -83,7 +83,7 @@ func TestTopicSubscriptionList(t *testing.T) {
Match: `event.type == "other"`,
}
err = server.AddTopicEventHandler(sub2, eventHandler)
assert.Nil(t, err)
require.NoError(t, err)
resp, err = server.ListTopicSubscriptions(context.Background(), &empty.Empty{})
require.NoError(t, err)
assert.NotNil(t, resp)
Expand All @@ -109,7 +109,7 @@ func TestTopicSubscriptionList(t *testing.T) {
Route: "/test",
}
err := server.AddBulkTopicEventHandler(sub1, eventHandler, 10, 1000)
assert.Nil(t, err)
require.NoError(t, err)
resp, err := server.ListTopicSubscriptions(context.Background(), &empty.Empty{})
require.NoError(t, err)
assert.NotNil(t, resp)
Expand All @@ -128,7 +128,7 @@ func TestTopicSubscriptionList(t *testing.T) {
Match: `event.type == "other"`,
}
err = server.AddBulkTopicEventHandler(sub2, eventHandler, 10, 1000)
assert.Nil(t, err)
require.NoError(t, err)
resp, err = server.ListTopicSubscriptions(context.Background(), &empty.Empty{})
require.NoError(t, err)
assert.NotNil(t, resp)
Expand Down Expand Up @@ -160,7 +160,7 @@ func TestTopic(t *testing.T) {
server := getTestServer()

err := server.AddTopicEventHandler(sub, eventHandler)
assert.Nil(t, err)
require.NoError(t, err)

startTestServer(server)

Expand Down Expand Up @@ -204,7 +204,7 @@ func TestTopic(t *testing.T) {
server := getTestServer()

err := server.AddBulkTopicEventHandler(sub, eventHandler, 10, 1000)
assert.Nil(t, err)
require.NoError(t, err)

startTestServer(server)

Expand Down Expand Up @@ -252,7 +252,7 @@ func TestTopicWithValidationDisabled(t *testing.T) {
server := getTestServer()

err := server.AddTopicEventHandler(sub, eventHandler)
assert.Nil(t, err)
require.NoError(t, err)

startTestServer(server)

Expand Down Expand Up @@ -281,7 +281,7 @@ func TestTopicWithValidationDisabled(t *testing.T) {
server := getTestServer()

err := server.AddBulkTopicEventHandler(sub, eventHandler, 10, 1000)
assert.Nil(t, err)
require.NoError(t, err)

startTestServer(server)

Expand Down Expand Up @@ -317,10 +317,10 @@ func TestTopicWithErrors(t *testing.T) {
server := getTestServer()

err := server.AddTopicEventHandler(sub1, eventHandlerWithRetryError)
assert.Nil(t, err)
require.NoError(t, err)

err = server.AddTopicEventHandler(sub2, eventHandlerWithError)
assert.Nil(t, err)
require.NoError(t, err)

startTestServer(server)

Expand Down Expand Up @@ -373,10 +373,10 @@ func TestTopicWithErrors(t *testing.T) {
server := getTestServer()

err := server.AddBulkTopicEventHandler(sub1, eventHandlerWithRetryError, 10, 1000)
assert.Nil(t, err)
require.NoError(t, err)

err = server.AddBulkTopicEventHandler(sub2, eventHandlerWithError, 10, 1000)
assert.Nil(t, err)
require.NoError(t, err)

startTestServer(server)

Expand Down Expand Up @@ -483,7 +483,7 @@ func TestEventDataHandling(t *testing.T) {
return false, nil
}
err := s.AddTopicEventHandler(sub, handler)
require.NoErrorf(t, err, "error adding event handler")
require.NoError(t, err, "error adding event handler")

startTestServer(s)

Expand Down Expand Up @@ -557,7 +557,7 @@ func TestEventDataHandling(t *testing.T) {
return false, nil
}
err := s.AddBulkTopicEventHandler(sub, handler, 10, 1000)
require.NoErrorf(t, err, "error adding event handler")
require.NoError(t, err, "error adding event handler")

startTestServer(s)

Expand Down

0 comments on commit 35c37bc

Please sign in to comment.