various: update tests for jobset state field changes
Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: Ifdd7f216fcc27fface0cb16d56c5e37b6a6a6964
This commit is contained in:
parent
865dd39a07
commit
10a118bd50
6 changed files with 16 additions and 1 deletions
|
|
@ -6,12 +6,14 @@ use regex::Regex;
|
|||
|
||||
/// Validate that a path is a valid nix store path.
|
||||
/// Rejects path traversal, overly long paths, and non-store paths.
|
||||
#[must_use]
|
||||
pub fn is_valid_store_path(path: &str) -> bool {
|
||||
path.starts_with("/nix/store/") && !path.contains("..") && path.len() < 512
|
||||
}
|
||||
|
||||
/// Validate that a string is a valid nix store hash (32 lowercase alphanumeric
|
||||
/// chars).
|
||||
#[must_use]
|
||||
pub fn is_valid_nix_hash(hash: &str) -> bool {
|
||||
hash.len() == 32
|
||||
&& hash
|
||||
|
|
@ -144,7 +146,7 @@ fn validate_forge_type(forge_type: &str) -> Result<(), String> {
|
|||
|
||||
// --- Implementations ---
|
||||
|
||||
use crate::models::*;
|
||||
use crate::models::{CreateProject, UpdateProject, CreateJobset, UpdateJobset, CreateEvaluation, CreateBuild, CreateChannel, UpdateChannel, CreateRemoteBuilder, UpdateRemoteBuilder, CreateWebhookConfig};
|
||||
|
||||
impl Validate for CreateProject {
|
||||
fn validate(&self) -> Result<(), String> {
|
||||
|
|
@ -478,6 +480,7 @@ mod tests {
|
|||
check_interval: Some(300),
|
||||
branch: None,
|
||||
scheduling_shares: None,
|
||||
state: None,
|
||||
};
|
||||
assert!(j.validate().is_ok());
|
||||
}
|
||||
|
|
@ -493,6 +496,7 @@ mod tests {
|
|||
check_interval: Some(5),
|
||||
branch: None,
|
||||
scheduling_shares: None,
|
||||
state: None,
|
||||
};
|
||||
assert!(j.validate().is_err());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,6 +49,7 @@ async fn create_test_jobset(
|
|||
check_interval: None,
|
||||
branch: None,
|
||||
scheduling_shares: None,
|
||||
state: None,
|
||||
})
|
||||
.await
|
||||
.expect("create jobset")
|
||||
|
|
@ -191,6 +192,7 @@ async fn test_jobset_crud() {
|
|||
check_interval: None,
|
||||
branch: None,
|
||||
scheduling_shares: None,
|
||||
state: None,
|
||||
})
|
||||
.await
|
||||
.expect("create jobset");
|
||||
|
|
@ -219,6 +221,7 @@ async fn test_jobset_crud() {
|
|||
check_interval: None,
|
||||
branch: None,
|
||||
scheduling_shares: None,
|
||||
state: None,
|
||||
})
|
||||
.await
|
||||
.expect("update jobset");
|
||||
|
|
|
|||
|
|
@ -116,6 +116,7 @@ async fn test_build_search_with_filters() {
|
|||
check_interval: None,
|
||||
branch: None,
|
||||
scheduling_shares: None,
|
||||
state: None,
|
||||
})
|
||||
.await
|
||||
.expect("create jobset");
|
||||
|
|
@ -261,6 +262,7 @@ async fn test_multi_entity_search() {
|
|||
check_interval: None,
|
||||
branch: None,
|
||||
scheduling_shares: None,
|
||||
state: None,
|
||||
})
|
||||
.await
|
||||
.expect("create jobset");
|
||||
|
|
@ -478,6 +480,7 @@ async fn test_quick_search() {
|
|||
check_interval: None,
|
||||
branch: None,
|
||||
scheduling_shares: None,
|
||||
state: None,
|
||||
})
|
||||
.await
|
||||
.expect("create jobset");
|
||||
|
|
|
|||
|
|
@ -363,6 +363,7 @@ async fn test_starred_jobs_crud() {
|
|||
check_interval: None,
|
||||
branch: None,
|
||||
scheduling_shares: None,
|
||||
state: None,
|
||||
})
|
||||
.await
|
||||
.expect("create jobset");
|
||||
|
|
@ -473,6 +474,7 @@ async fn test_starred_jobs_delete_by_job() {
|
|||
check_interval: None,
|
||||
branch: None,
|
||||
scheduling_shares: None,
|
||||
state: None,
|
||||
})
|
||||
.await
|
||||
.expect("create jobset");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue