-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
89 additions
and
18 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 |
---|---|---|
@@ -0,0 +1,49 @@ | ||
use std::env; | ||
|
||
use bios_basic::process::task_processor::TaskProcessor; | ||
use bios_basic::test::init_test_container; | ||
use tardis::basic::result::TardisResult; | ||
use tardis::{testcontainers, tokio, TardisFuns}; | ||
|
||
#[tokio::test] | ||
async fn test_task_processor() -> TardisResult<()> { | ||
env::set_var("RUST_LOG", "debug,test_iam_serv=trace,sqlx::query=off,sqlparser=off"); | ||
let docker = testcontainers::clients::Cli::default(); | ||
let _x = init_test_container::init(&docker, None).await?; | ||
|
||
let cache_client = TardisFuns::inst("".to_string(), None).cache(); | ||
|
||
TaskProcessor::set_status("test1", 1, true, &cache_client).await?; | ||
assert!(TaskProcessor::check_status("test1", 1, &cache_client).await?); | ||
assert!(!TaskProcessor::check_status("test1", u32::MAX as u64, &cache_client).await?); | ||
assert!(!TaskProcessor::check_status("test1", u32::MAX as u64 + 1, &cache_client).await?); | ||
assert!(!TaskProcessor::check_status("test1", u64::MAX, &cache_client).await?); | ||
|
||
TaskProcessor::set_status("test1", u32::MAX as u64, true, &cache_client).await?; | ||
assert!(TaskProcessor::check_status("test1", 1, &cache_client).await?); | ||
assert!(TaskProcessor::check_status("test1", u32::MAX as u64, &cache_client).await?); | ||
assert!(!TaskProcessor::check_status("test1", u32::MAX as u64 + 1, &cache_client).await?); | ||
assert!(!TaskProcessor::check_status("test1", u64::MAX, &cache_client).await?); | ||
|
||
TaskProcessor::set_status("test1", u32::MAX as u64 + 1, true, &cache_client).await?; | ||
assert!(TaskProcessor::check_status("test1", 1, &cache_client).await?); | ||
assert!(TaskProcessor::check_status("test1", u32::MAX as u64, &cache_client).await?); | ||
assert!(TaskProcessor::check_status("test1", u32::MAX as u64 + 1, &cache_client).await?); | ||
assert!(!TaskProcessor::check_status("test1", u64::MAX, &cache_client).await?); | ||
|
||
TaskProcessor::set_status("test1", u64::MAX, true, &cache_client).await?; | ||
assert!(TaskProcessor::check_status("test1", 1, &cache_client).await?); | ||
assert!(TaskProcessor::check_status("test1", u32::MAX as u64, &cache_client).await?); | ||
assert!(TaskProcessor::check_status("test1", u32::MAX as u64 + 1, &cache_client).await?); | ||
assert!(TaskProcessor::check_status("test1", u64::MAX, &cache_client).await?); | ||
|
||
TaskProcessor::set_status("test1", 1, false, &cache_client).await?; | ||
assert!(!TaskProcessor::check_status("test1", 1, &cache_client).await?); | ||
assert!(TaskProcessor::check_status("test1", u32::MAX as u64, &cache_client).await?); | ||
assert!(TaskProcessor::check_status("test1", u32::MAX as u64 + 1, &cache_client).await?); | ||
assert!(TaskProcessor::check_status("test1", u64::MAX, &cache_client).await?); | ||
|
||
assert!(!TaskProcessor::check_status("test2", u32::MAX as u64 + 1, &cache_client).await?); | ||
|
||
Ok(()) | ||
} |