package notificationservice import ( "context" "errors" "testing" "Yimaru-Backend/internal/ports" ) type deleteInAppStoreStub struct { ports.NotificationStore singleRows int64 singleErr error bulkRows int64 bulkErr error } func (s *deleteInAppStoreStub) DeleteUserInAppNotification(_ context.Context, _, _ int64) (int64, error) { if s.singleErr != nil { return 0, s.singleErr } return s.singleRows, nil } func (s *deleteInAppStoreStub) DeleteUserInAppNotificationsByIDs(_ context.Context, _ int64, _ []int64) (int64, error) { if s.bulkErr != nil { return 0, s.bulkErr } return s.bulkRows, nil } func TestDeleteUserInAppNotification_success(t *testing.T) { svc := &Service{ store: &deleteInAppStoreStub{singleRows: 1}, } if err := svc.DeleteUserInAppNotification(context.Background(), 10, 42); err != nil { t.Fatalf("expected nil error, got %v", err) } } func TestDeleteUserInAppNotification_notFound(t *testing.T) { svc := &Service{ store: &deleteInAppStoreStub{singleRows: 0}, } err := svc.DeleteUserInAppNotification(context.Background(), 10, 42) if !errors.Is(err, ErrNotificationNotFound) { t.Fatalf("expected ErrNotificationNotFound, got %v", err) } } func TestDeleteUserInAppNotifications_success(t *testing.T) { svc := &Service{ store: &deleteInAppStoreStub{bulkRows: 2}, } got, err := svc.DeleteUserInAppNotifications(context.Background(), 42, []int64{1, 2, 3}) if err != nil { t.Fatalf("expected nil error, got %v", err) } if got != 2 { t.Fatalf("expected deleted count 2, got %d", got) } }