Skip to content

Commit

Permalink
refactor: reduce tokio::test
Browse files Browse the repository at this point in the history
  • Loading branch information
tmtmtoo committed Jan 5, 2024
1 parent 730bd88 commit 0fcf78c
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 10 deletions.
37 changes: 37 additions & 0 deletions Cargo.lock

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

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,7 @@ structopt = "0.3.26"

[dev-dependencies]
assert_cmd = "1.0.1"
futures-lite = "2.1.0"
lite-async-test = "0.1.2"
mockall = "0.12.1"
predicates = "1.0.5"
2 changes: 1 addition & 1 deletion src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ mod tests {
}
}

#[tokio::test]
#[lite_async_test::async_test]
async fn run_must_be_done() {
let actual = run(0).await;
let expected = 5;
Expand Down
10 changes: 5 additions & 5 deletions src/app/retry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ mod tests {
}
}

#[tokio::test]
#[lite_async_test::async_test]
async fn exec_cmd_to_done_with_success() {
let app = RetryApp::<TestE, TestS> {
state: State::ExecuteCommand(TestE {
Expand All @@ -170,7 +170,7 @@ mod tests {
));
}

#[tokio::test]
#[lite_async_test::async_test]
async fn exec_cmd_to_sleep_without_limit() {
let app = RetryApp::<TestE, TestS> {
state: State::ExecuteCommand(TestE {
Expand All @@ -190,7 +190,7 @@ mod tests {
});
}

#[tokio::test]
#[lite_async_test::async_test]
async fn exec_cmd_to_sleep_with_limit() {
let app = RetryApp::<TestE, TestS> {
state: State::ExecuteCommand(TestE {
Expand Down Expand Up @@ -218,7 +218,7 @@ mod tests {
);
}

#[tokio::test]
#[lite_async_test::async_test]
async fn exec_cmd_to_done_with_fail() {
let app = RetryApp::<TestE, TestS> {
state: State::ExecuteCommand(TestE {
Expand All @@ -233,7 +233,7 @@ mod tests {
));
}

#[tokio::test]
#[lite_async_test::async_test]
async fn sleep_to_exec() {
let app = RetryApp::<TestE, TestS> {
state: State::Sleep(TestS),
Expand Down
8 changes: 4 additions & 4 deletions src/app/supervise.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ mod tests {
}
}

#[tokio::test]
#[lite_async_test::async_test]
async fn exec_cmd_to_sleep_without_limit() {
let app = SuperviseApp::<TestE, TestS> {
state: State::ExecuteCommand(TestE),
Expand All @@ -164,7 +164,7 @@ mod tests {
});
}

#[tokio::test]
#[lite_async_test::async_test]
async fn exec_cmd_to_sleep_with_limit() {
let app = SuperviseApp::<TestE, TestS> {
state: State::ExecuteCommand(TestE),
Expand All @@ -182,7 +182,7 @@ mod tests {
});
}

#[tokio::test]
#[lite_async_test::async_test]
async fn exec_cmd_to_done() {
let app = SuperviseApp::<TestE, TestS> {
state: State::ExecuteCommand(TestE),
Expand All @@ -195,7 +195,7 @@ mod tests {
});
}

#[tokio::test]
#[lite_async_test::async_test]
async fn sleep_to_exec() {
let app = SuperviseApp::<TestE, TestS> {
state: State::Sleep(TestS),
Expand Down

0 comments on commit 0fcf78c

Please sign in to comment.