This repository has been archived by the owner on Oct 31, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Simon Paitrault <simon.paitrault@gmail.com>
- Loading branch information
Showing
7 changed files
with
125 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
pub mod builder; | ||
mod query; | ||
mod routes; | ||
#[cfg(test)] | ||
mod tests; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
use std::time::Duration; | ||
|
||
use crate::{ | ||
graphql::query::SubscriptionRoot, runtime::InternalRuntimeCommand, stream::TransientStream, | ||
}; | ||
use rstest::rstest; | ||
use test_log::test; | ||
use tokio::sync::{mpsc, oneshot}; | ||
use uuid::Uuid; | ||
|
||
#[rstest] | ||
#[test(tokio::test)] | ||
#[timeout(Duration::from_secs(2))] | ||
async fn requesting_transiant_stream_from_graphql() { | ||
let (sender, mut receiver) = mpsc::channel(1); | ||
|
||
tokio::spawn(async move { | ||
let mut v = Vec::new(); | ||
while let Some(query) = receiver.recv().await { | ||
if let InternalRuntimeCommand::NewTransientStream { sender } = query { | ||
let (notifier, notifier_receiver) = oneshot::channel(); | ||
v.push(notifier_receiver); | ||
|
||
let (_s, inner) = mpsc::channel(10); | ||
_ = sender.send(Ok(TransientStream { | ||
stream_id: Uuid::new_v4(), | ||
notifier: Some(notifier), | ||
inner, | ||
})); | ||
} | ||
} | ||
}); | ||
let root = SubscriptionRoot {}; | ||
|
||
let result = root.new_transient_stream(&sender).await; | ||
|
||
assert!(result.is_ok()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters