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.
|
/// Validate that a path is a valid nix store path.
|
||||||
/// Rejects path traversal, overly long paths, and non-store paths.
|
/// Rejects path traversal, overly long paths, and non-store paths.
|
||||||
|
#[must_use]
|
||||||
pub fn is_valid_store_path(path: &str) -> bool {
|
pub fn is_valid_store_path(path: &str) -> bool {
|
||||||
path.starts_with("/nix/store/") && !path.contains("..") && path.len() < 512
|
path.starts_with("/nix/store/") && !path.contains("..") && path.len() < 512
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Validate that a string is a valid nix store hash (32 lowercase alphanumeric
|
/// Validate that a string is a valid nix store hash (32 lowercase alphanumeric
|
||||||
/// chars).
|
/// chars).
|
||||||
|
#[must_use]
|
||||||
pub fn is_valid_nix_hash(hash: &str) -> bool {
|
pub fn is_valid_nix_hash(hash: &str) -> bool {
|
||||||
hash.len() == 32
|
hash.len() == 32
|
||||||
&& hash
|
&& hash
|
||||||
|
|
@ -144,7 +146,7 @@ fn validate_forge_type(forge_type: &str) -> Result<(), String> {
|
||||||
|
|
||||||
// --- Implementations ---
|
// --- Implementations ---
|
||||||
|
|
||||||
use crate::models::*;
|
use crate::models::{CreateProject, UpdateProject, CreateJobset, UpdateJobset, CreateEvaluation, CreateBuild, CreateChannel, UpdateChannel, CreateRemoteBuilder, UpdateRemoteBuilder, CreateWebhookConfig};
|
||||||
|
|
||||||
impl Validate for CreateProject {
|
impl Validate for CreateProject {
|
||||||
fn validate(&self) -> Result<(), String> {
|
fn validate(&self) -> Result<(), String> {
|
||||||
|
|
@ -478,6 +480,7 @@ mod tests {
|
||||||
check_interval: Some(300),
|
check_interval: Some(300),
|
||||||
branch: None,
|
branch: None,
|
||||||
scheduling_shares: None,
|
scheduling_shares: None,
|
||||||
|
state: None,
|
||||||
};
|
};
|
||||||
assert!(j.validate().is_ok());
|
assert!(j.validate().is_ok());
|
||||||
}
|
}
|
||||||
|
|
@ -493,6 +496,7 @@ mod tests {
|
||||||
check_interval: Some(5),
|
check_interval: Some(5),
|
||||||
branch: None,
|
branch: None,
|
||||||
scheduling_shares: None,
|
scheduling_shares: None,
|
||||||
|
state: None,
|
||||||
};
|
};
|
||||||
assert!(j.validate().is_err());
|
assert!(j.validate().is_err());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -49,6 +49,7 @@ async fn create_test_jobset(
|
||||||
check_interval: None,
|
check_interval: None,
|
||||||
branch: None,
|
branch: None,
|
||||||
scheduling_shares: None,
|
scheduling_shares: None,
|
||||||
|
state: None,
|
||||||
})
|
})
|
||||||
.await
|
.await
|
||||||
.expect("create jobset")
|
.expect("create jobset")
|
||||||
|
|
@ -191,6 +192,7 @@ async fn test_jobset_crud() {
|
||||||
check_interval: None,
|
check_interval: None,
|
||||||
branch: None,
|
branch: None,
|
||||||
scheduling_shares: None,
|
scheduling_shares: None,
|
||||||
|
state: None,
|
||||||
})
|
})
|
||||||
.await
|
.await
|
||||||
.expect("create jobset");
|
.expect("create jobset");
|
||||||
|
|
@ -219,6 +221,7 @@ async fn test_jobset_crud() {
|
||||||
check_interval: None,
|
check_interval: None,
|
||||||
branch: None,
|
branch: None,
|
||||||
scheduling_shares: None,
|
scheduling_shares: None,
|
||||||
|
state: None,
|
||||||
})
|
})
|
||||||
.await
|
.await
|
||||||
.expect("update jobset");
|
.expect("update jobset");
|
||||||
|
|
|
||||||
|
|
@ -116,6 +116,7 @@ async fn test_build_search_with_filters() {
|
||||||
check_interval: None,
|
check_interval: None,
|
||||||
branch: None,
|
branch: None,
|
||||||
scheduling_shares: None,
|
scheduling_shares: None,
|
||||||
|
state: None,
|
||||||
})
|
})
|
||||||
.await
|
.await
|
||||||
.expect("create jobset");
|
.expect("create jobset");
|
||||||
|
|
@ -261,6 +262,7 @@ async fn test_multi_entity_search() {
|
||||||
check_interval: None,
|
check_interval: None,
|
||||||
branch: None,
|
branch: None,
|
||||||
scheduling_shares: None,
|
scheduling_shares: None,
|
||||||
|
state: None,
|
||||||
})
|
})
|
||||||
.await
|
.await
|
||||||
.expect("create jobset");
|
.expect("create jobset");
|
||||||
|
|
@ -478,6 +480,7 @@ async fn test_quick_search() {
|
||||||
check_interval: None,
|
check_interval: None,
|
||||||
branch: None,
|
branch: None,
|
||||||
scheduling_shares: None,
|
scheduling_shares: None,
|
||||||
|
state: None,
|
||||||
})
|
})
|
||||||
.await
|
.await
|
||||||
.expect("create jobset");
|
.expect("create jobset");
|
||||||
|
|
|
||||||
|
|
@ -363,6 +363,7 @@ async fn test_starred_jobs_crud() {
|
||||||
check_interval: None,
|
check_interval: None,
|
||||||
branch: None,
|
branch: None,
|
||||||
scheduling_shares: None,
|
scheduling_shares: None,
|
||||||
|
state: None,
|
||||||
})
|
})
|
||||||
.await
|
.await
|
||||||
.expect("create jobset");
|
.expect("create jobset");
|
||||||
|
|
@ -473,6 +474,7 @@ async fn test_starred_jobs_delete_by_job() {
|
||||||
check_interval: None,
|
check_interval: None,
|
||||||
branch: None,
|
branch: None,
|
||||||
scheduling_shares: None,
|
scheduling_shares: None,
|
||||||
|
state: None,
|
||||||
})
|
})
|
||||||
.await
|
.await
|
||||||
.expect("create jobset");
|
.expect("create jobset");
|
||||||
|
|
|
||||||
|
|
@ -144,6 +144,7 @@ async fn test_atomic_build_claiming() {
|
||||||
check_interval: None,
|
check_interval: None,
|
||||||
branch: None,
|
branch: None,
|
||||||
scheduling_shares: None,
|
scheduling_shares: None,
|
||||||
|
state: None,
|
||||||
})
|
})
|
||||||
.await
|
.await
|
||||||
.expect("create jobset");
|
.expect("create jobset");
|
||||||
|
|
@ -235,6 +236,7 @@ async fn test_orphan_build_reset() {
|
||||||
check_interval: None,
|
check_interval: None,
|
||||||
branch: None,
|
branch: None,
|
||||||
scheduling_shares: None,
|
scheduling_shares: None,
|
||||||
|
state: None,
|
||||||
})
|
})
|
||||||
.await
|
.await
|
||||||
.expect("create jobset");
|
.expect("create jobset");
|
||||||
|
|
|
||||||
|
|
@ -63,6 +63,7 @@ async fn test_e2e_project_eval_build_flow() {
|
||||||
check_interval: Some(300),
|
check_interval: Some(300),
|
||||||
branch: None,
|
branch: None,
|
||||||
scheduling_shares: None,
|
scheduling_shares: None,
|
||||||
|
state: None,
|
||||||
})
|
})
|
||||||
.await
|
.await
|
||||||
.expect("create jobset");
|
.expect("create jobset");
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue