sova-testing 0.1.1

Framework-style test harness for Sova (sqlite, acting_as, factories, snapshots)
Documentation
//! Notifications-only `acting_as_id` (no auth feature).

use sova_core::TestClient;
use sova_notifications::NotificationUser;

/// Inject [`NotificationUser`] on every request.
pub trait ActingAs {
    fn acting_as_id(&self, user_id: i64);
    fn logout(&self);
}

impl ActingAs for TestClient {
    fn acting_as_id(&self, user_id: i64) {
        self.clear_request_hooks();
        self.on_request(move |req| {
            req.set(NotificationUser(user_id));
        });
    }

    fn logout(&self) {
        self.clear_request_hooks();
    }
}