Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
cablehead committed May 18, 2024
1 parent 4ed44ef commit 6739d8b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ async fn get(store: Store, req: Request<hyper::body::Incoming>) -> HTTPResult {
Err(err) => return response_400(err),
};

let rx = store.subscribe(options).await;
let rx = store.read(options).await;
let stream = ReceiverStream::new(rx);
let stream = stream.map(|frame| {
eprintln!("streaming");
Expand Down
16 changes: 14 additions & 2 deletions src/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ impl Store {
store
}

pub async fn subscribe(&self, options: ReadOptions) -> mpsc::Receiver<Frame> {
pub async fn read(&self, options: ReadOptions) -> mpsc::Receiver<Frame> {
let (tx, rx) = mpsc::channel::<Frame>(100);
self.commands_tx
.send(Command::Read(tx, options))
Expand Down Expand Up @@ -153,7 +153,7 @@ mod tests {
use static_assertions::assert_impl_all;

#[test]
fn store_send_sync() {
fn test_store_is_send_sync() {
assert_impl_all!(Store: Send, Sync);
}
}
Expand Down Expand Up @@ -237,3 +237,15 @@ mod tests_read_options {
assert!(ReadOptions::from_query(Some("last-id=123")).is_err());
}
}

#[cfg(test)]
mod tests_store {
use super::*;
use tempfile::TempDir;

#[tokio::test]
async fn test_basics() {
let temp_dir = TempDir::new().unwrap();
let store = Store::spawn(temp_dir.into_path());
}
}
2 changes: 1 addition & 1 deletion tests/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ async fn test_integration() {
)
)
.read()
.expect("Failed to run date | curl command");
.unwrap();

assert_eq!("123", &output);

Expand Down

0 comments on commit 6739d8b

Please sign in to comment.