topfans/backend/services/socialService/client/notification_client_mock.go
2026-06-16 21:30:58 +08:00

29 lines
803 B
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package client
import (
"context"
"sync"
notifPb "github.com/topfans/backend/pkg/proto/notification"
)
// MockNotificationClient 通知客户端 mock用于测试
// 实现 NotificationClientInterface 约定,便于在单元测试中注入。
type MockNotificationClient struct {
mu sync.Mutex
CreateErr error
CreateCallCount int32
LastRequest *notifPb.CreateNotificationRequest
}
// CreateNotification 模拟调用
func (m *MockNotificationClient) CreateNotification(ctx context.Context, req *notifPb.CreateNotificationRequest) (*notifPb.CreateNotificationResponse, error) {
m.mu.Lock()
defer m.mu.Unlock()
m.CreateCallCount++
m.LastRequest = req
if m.CreateErr != nil {
return nil, m.CreateErr
}
return &notifPb.CreateNotificationResponse{Id: 1}, nil
}