feat: Fix tests on github actions

Add better panic

chore: Use unwrap instead of ? for debugging ♻️

chore: Remove table tests ♻️

chore: Make terminal::size unwrap to default values ♻️

chore: Move reader creation to inside init check ♻️

fix: Change total_tasks in tests 🐛

fix: Change default height 🐛

chore: Print taskwarrior version ♻️

chore: Build taskwarrior from source for tests ♻️

chore: Checkout v2.6.1 of taskwarrior for tests ♻️

chore: Use ? instead of unwrap ♻️

chore: fix tests ♻️
This commit is contained in:
Dheepak Krishnamurthy 2022-04-27 16:11:10 -06:00
parent 5ffa14d64b
commit 8b26a8a688
4 changed files with 19 additions and 27 deletions

View file

@ -31,13 +31,22 @@ jobs:
profile: minimal
toolchain: stable
override: true
- run: sudo apt-get update && sudo apt-get install -y taskwarrior
- run: sudo apt-get update
- name: Compile taskwarrior
run: |
cd /tmp
git clone https://github.com/GothenburgBitFactory/taskwarrior
cd taskwarrior
git checkout v2.6.1
cmake -DCMAKE_BUILD_TYPE=release -DENABLE_SYNC=OFF .
make
sudo make install
- uses: actions/checkout@v2
with:
repository: kdheepak/taskwarrior-testdata
path: taskwarrior-testdata
- run: |
ulimit -a
task --version
- run: |
# prepare taskwarrior, initial setup
task rc.confirmation=off || echo 0

View file

@ -245,15 +245,13 @@ impl TaskwarriorTui {
.arg("rc.defaultwidth=0")
.arg("show")
.output()
.context("Unable to run `task show`.")
.unwrap();
.context("Unable to run `task show`.")?;
if !output.status.success() {
let output = std::process::Command::new("task")
.arg("diagnostics")
.output()
.context("Unable to run `task diagnostics`.")
.unwrap();
.context("Unable to run `task diagnostics`.")?;
return Err(anyhow!(
"Unable to run `task show`.\n{}\n{}\nPlease check your configuration or open a issue on github.",
String::from_utf8_lossy(&output.stdout),
@ -268,12 +266,12 @@ impl TaskwarriorTui {
let output = std::process::Command::new("task")
.arg("--version")
.output()
.context("Unable to run `task --version`")
.unwrap();
.context("Unable to run `task --version`")?;
let task_version = Versioning::new(String::from_utf8_lossy(&output.stdout).trim()).unwrap();
let task_version =
Versioning::new(String::from_utf8_lossy(&output.stdout).trim()).context("Unable to get version string")?;
let (w, h) = crossterm::terminal::size()?;
let (w, h) = crossterm::terminal::size().unwrap_or((50, 15));
let tick_rate = if c.uda_tick_rate > 0 {
Some(std::time::Duration::from_millis(c.uda_tick_rate))
@ -3874,11 +3872,7 @@ mod tests {
}
async fn _test_taskwarrior_tui() {
let app = TaskwarriorTui::new("next", false).await;
if app.is_err() {
return;
}
let app = app.unwrap();
let app = TaskwarriorTui::new("next", false).await.unwrap();
assert!(app.task_by_index(0).is_none(), "Expected task data to be empty but found {} tasks. Delete contents of {:?} and {:?} and run the tests again.", app.tasks.len(), Path::new(env!("TASKDATA")), Path::new(env!("TASKDATA")).parent().unwrap().join(".config"));

View file

@ -56,13 +56,13 @@ impl EventLoop {
pub fn new(tick_rate: Option<std::time::Duration>, init: bool) -> Self {
let (tx, rx) = mpsc::unbounded_channel();
let _tx = tx.clone();
let mut reader = crossterm::event::EventStream::new();
let should_tick = tick_rate.is_some();
let tick_rate = tick_rate.unwrap_or(std::time::Duration::from_millis(250));
let (abort, mut abort_recv) = mpsc::unbounded_channel();
if init {
let mut reader = crossterm::event::EventStream::new();
tokio::spawn(async move {
loop {
let delay = tokio::time::sleep(tick_rate);

View file

@ -540,14 +540,3 @@ where
StatefulWidget::render(self, area, buf, &mut state);
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
#[should_panic]
fn table_invalid_percentages() {
Table::new([""].iter(), vec![Row::Data([""].iter())].into_iter()).widths(&[Constraint::Percentage(110)]);
}
}