Skip to content

Commit

Permalink
Added infrastructure to do integration testing.
Browse files Browse the repository at this point in the history
  • Loading branch information
apognu committed Apr 30, 2024
1 parent 71cf19e commit e0ec54d
Show file tree
Hide file tree
Showing 14 changed files with 889 additions and 50 deletions.
125 changes: 90 additions & 35 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,8 @@ tracing = "0.1.40"

[profile.release]
lto = true

[dev-dependencies]
greetd-stub = "0.2.0"
tempfile = "3.10.1"
unicode-width = "0.1.12"
12 changes: 11 additions & 1 deletion src/event.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
use std::time::Duration;

use crossterm::event::{Event as TermEvent, EventStream, KeyEvent};
use crossterm::event::{Event as TermEvent, KeyEvent};
use futures::{future::FutureExt, StreamExt};
use tokio::{
process::Command,
sync::mpsc::{self, Sender},
};

#[cfg(not(test))]
use crossterm::event::EventStream;

use crate::AuthStatus;

const FRAME_RATE: f64 = 2.0;
Expand All @@ -31,7 +34,14 @@ impl Events {
let tx = tx.clone();

async move {
#[cfg(not(test))]
let mut stream = EventStream::new();

// In tests, we are not capturing events from the terminal, so we need
// to replace the crossterm::EventStream with a dummy pending stream.
#[cfg(test)]
let mut stream = futures::stream::pending::<Result<TermEvent, ()>>();

let mut render_interval = tokio::time::interval(Duration::from_secs_f64(1.0 / FRAME_RATE));

loop {
Expand Down
1 change: 1 addition & 0 deletions src/greeter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ impl Greeter {
selected: 0,
};

#[cfg(not(test))]
greeter.parse_options().await;

greeter.sessions = Menu {
Expand Down
Loading

0 comments on commit e0ec54d

Please sign in to comment.