Skip to content

Commit

Permalink
Export types instead of modules for testing purposes
Browse files Browse the repository at this point in the history
Our end-to-end test as well as the terminal UI example both peek into a
bunch of program internals for their reuse. So far this was made
possible by exposing the containing modules publicly. That is an overly
broad exposure and it leaks the internal structure of the program to the
"outside".
This change takes a different route, exposing only the types strictly
necessary to be exposed, but keeping their containing modules private.
  • Loading branch information
d-e-s-o committed May 7, 2023
1 parent 6253727 commit 7f280cc
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
6 changes: 3 additions & 3 deletions examples/with-test-data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ use std::io::stdout;

use anyhow::Result;

use notnow::cap::DirCap;
use notnow::run_prog;
use notnow::state::TaskState;
use notnow::state::UiConfig;
use notnow::test::default_tasks_and_tags;
use notnow::DirCap;
use notnow::TaskState;
use notnow::UiConfig;

use tempfile::TempDir;

Expand Down
11 changes: 6 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,22 +60,26 @@

//! A terminal based task management application.
pub mod cap;
mod cap;
mod colors;
mod db;
mod id;
mod ops;
mod position;
mod resize;
mod ser;
pub mod state;
mod state;
mod tags;
mod tasks;
#[cfg(any(test, feature = "test"))]
pub mod test;
mod ui;
mod view;

pub use crate::cap::DirCap;
pub use crate::state::TaskState;
pub use crate::state::UiConfig;

use std::env::args_os;
use std::ffi::OsString;
use std::fs::create_dir_all;
Expand Down Expand Up @@ -116,10 +120,7 @@ use tokio::runtime::Builder;
use gui::Renderer;
use gui::Ui;

use crate::cap::DirCap;
use crate::resize::receive_window_resizes;
use crate::state::TaskState;
use crate::state::UiConfig;
use crate::ui::Event as UiEvent;
use crate::ui::Message;
use crate::ui::Renderer as TermUiRenderer;
Expand Down
6 changes: 3 additions & 3 deletions tests/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
use std::ffi::OsString;
use std::io::sink;

use notnow::cap::DirCap;
use notnow::run_prog;
use notnow::state::TaskState;
use notnow::state::UiConfig;
use notnow::test::default_tasks_and_tags;
use notnow::DirCap;
use notnow::TaskState;
use notnow::UiConfig;

use tempfile::TempDir;

Expand Down

0 comments on commit 7f280cc

Please sign in to comment.