From 5479c64fe0d015ab48560f06ab0f121b4caaf3e1 Mon Sep 17 00:00:00 2001 From: kevin Date: Wed, 24 Jul 2024 18:00:49 +0800 Subject: [PATCH] chore: refactor test code --- kq/pusher_test.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/kq/pusher_test.go b/kq/pusher_test.go index affb78a..72b380d 100644 --- a/kq/pusher_test.go +++ b/kq/pusher_test.go @@ -11,17 +11,17 @@ import ( "github.com/stretchr/testify/mock" ) -// MockKafkaWriter is a mock for kafka.Writer -type MockKafkaWriter struct { +// mockKafkaWriter is a mock for kafka.Writer +type mockKafkaWriter struct { mock.Mock } -func (m *MockKafkaWriter) WriteMessages(ctx context.Context, msgs ...kafka.Message) error { +func (m *mockKafkaWriter) WriteMessages(ctx context.Context, msgs ...kafka.Message) error { args := m.Called(ctx, msgs) return args.Error(0) } -func (m *MockKafkaWriter) Close() error { +func (m *mockKafkaWriter) Close() error { args := m.Called() return args.Error(0) } @@ -66,7 +66,7 @@ func TestNewPusher(t *testing.T) { } func TestPusher_Close(t *testing.T) { - mockWriter := new(MockKafkaWriter) + mockWriter := new(mockKafkaWriter) pusher := &Pusher{ producer: mockWriter, } @@ -86,7 +86,7 @@ func TestPusher_Name(t *testing.T) { } func TestPusher_Push(t *testing.T) { - mockWriter := new(MockKafkaWriter) + mockWriter := new(mockKafkaWriter) pusher := &Pusher{ producer: mockWriter, topic: "test-topic", @@ -103,7 +103,7 @@ func TestPusher_Push(t *testing.T) { } func TestPusher_PushWithKey(t *testing.T) { - mockWriter := new(MockKafkaWriter) + mockWriter := new(mockKafkaWriter) pusher := &Pusher{ producer: mockWriter, topic: "test-topic", @@ -121,7 +121,7 @@ func TestPusher_PushWithKey(t *testing.T) { } func TestPusher_PushWithKey_Error(t *testing.T) { - mockWriter := new(MockKafkaWriter) + mockWriter := new(mockKafkaWriter) pusher := &Pusher{ producer: mockWriter, topic: "test-topic",