use super::{Platform, RepoContext};
use std::path::PathBuf;
#[derive(Debug, Clone)]
pub struct SystemContext {
pub hostname: String,
pub platform: Platform,
pub claude_root: PathBuf,
pub claude_version: String,
pub schema_version: Option<()>,
pub repo: Option<RepoContext>,
pub default_team: String,
}
impl SystemContext {
pub fn new(
hostname: String,
platform: Platform,
claude_root: PathBuf,
claude_version: String,
default_team: String,
) -> Self {
Self {
hostname,
platform,
claude_root,
claude_version,
schema_version: None, repo: None,
default_team,
}
}
pub fn with_repo(mut self, repo: RepoContext) -> Self {
self.repo = Some(repo);
self
}
pub fn with_schema_version(mut self, _version: ()) -> Self {
self.schema_version = Some(());
self
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_system_context_new() {
let ctx = SystemContext::new(
"test-host".to_string(),
Platform::Linux,
PathBuf::from("/home/user/.claude"),
"2.1.39".to_string(),
"default-team".to_string(),
);
assert_eq!(ctx.hostname, "test-host");
assert_eq!(ctx.platform, Platform::Linux);
assert_eq!(ctx.claude_root, PathBuf::from("/home/user/.claude"));
assert_eq!(ctx.claude_version, "2.1.39");
assert_eq!(ctx.default_team, "default-team");
assert!(ctx.repo.is_none());
assert!(ctx.schema_version.is_none());
}
#[test]
fn test_system_context_with_repo() {
let repo = RepoContext::new(
"test-repo".to_string(),
PathBuf::from("/path/to/repo"),
);
let ctx = SystemContext::new(
"test-host".to_string(),
Platform::Linux,
PathBuf::from("/home/user/.claude"),
"2.1.39".to_string(),
"default-team".to_string(),
)
.with_repo(repo);
assert!(ctx.repo.is_some());
assert_eq!(ctx.repo.unwrap().name, "test-repo");
}
}