Files
honey-biscuit-workshop/workshop-baker/tests/prebake_config_integration.rs
T
Catty Steve 50b42e654c refactor(workshop-engine): replace tokio Child with ManagedChild trait
for testability

- Add `ManagedChild` trait abstracting process lifecycle (real
  `TokioChild` + `MockChild` for tests)
- Use Unix process groups (`process_group(0)` + `libc::kill(-pgid,
  SIGKILL)`) for tree-wide termination
- Remove cgroup-related code (`CgroupManager`, `ResourceUsage`,
  `cgroup_path` field)
- Update imports across test files to use `workshop-engine` crate
  directly
2026-04-27 12:02:17 +08:00

80 lines
1.7 KiB
Rust

use workshop_baker::prebake::parse;
use workshop_baker::prebake::types::builderconfig::BuilderType;
#[test]
fn test_prebake_config_minimal_yaml() {
let yaml = r#"
version: "1.0"
environment:
builder: docker
"#;
let config = parse(yaml).unwrap();
assert_eq!(config.version, "1.0");
assert_eq!(config.environment.builder, BuilderType::Docker);
}
#[test]
fn test_prebake_config_with_builder_type_baremetal() {
let yaml = r#"
version: "1.0"
environment:
builder: baremetal
"#;
let config = parse(yaml).unwrap();
assert_eq!(config.environment.builder, BuilderType::Baremetal);
}
#[test]
fn test_prebake_config_with_envvars() {
let yaml = r#"
version: "1.0"
environment:
builder: baremetal
envvars:
prebake:
RUST_LOG: debug
"#;
let config = parse(yaml).unwrap();
assert_eq!(config.environment.builder, BuilderType::Baremetal);
let prebake_vars = config.envvars.unwrap().prebake.unwrap();
assert_eq!(prebake_vars.get("RUST_LOG").unwrap(), "debug");
}
#[test]
fn test_prebake_config_with_bootstrap_workspace() {
let yaml = r#"
version: "1.0"
environment:
builder: docker
bootstrap:
workspace:
path: "/workspace"
"#;
let config = parse(yaml).unwrap();
let bootstrap = config.bootstrap.unwrap();
let workspace = bootstrap.workspace.unwrap();
assert_eq!(workspace.path, "/workspace");
}
#[test]
fn test_prebake_config_validation_passes() {
let yaml = r#"
version: "1.0"
environment:
builder: docker
"#;
let config = parse(yaml).unwrap();
assert!(config.validate().is_ok());
}
#[test]
fn test_prebake_config_validation_fails_bad_version() {
let yaml = r#"
version: "99.0"
environment:
builder: docker
"#;
let config = parse(yaml).unwrap();
assert!(config.validate().is_err());
}