Skip to content

Commit

Permalink
[ADD] Added few more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lordofwizard committed Oct 17, 2024
1 parent 8d8eec5 commit bb787ba
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -319,4 +319,35 @@ mod tests {
assert_eq!(config.project_name, "unknown"); // Missing section
assert_eq!(config.online_mode, false); // Missing section
}

#[test]
fn test_missing_version() {
// Set the current working directory to /tmp
env::set_current_dir("/tmp").expect("Failed to change cwd to /tmp");

let toml_content = r#""#; // Empty content

// Create a temporary project directory with empty config.toml inside
let project_name = "my_project_missing_version";
let _project_dir = create_project_with_toml(project_name, toml_content);

let config = Config::new(project_name);

assert_eq!(config.version, "unknown"); // Missing section
}
#[test]
fn test_missing_java() {
// Set the current working directory to /tmp
env::set_current_dir("/tmp").expect("Failed to change cwd to /tmp");

let toml_content = r#""#; // Empty content

// Create a temporary project directory with empty config.toml inside
let project_name = "my_project_missing_java";
let _project_dir = create_project_with_toml(project_name, toml_content);

let config = Config::new(project_name);

assert_eq!(config.java, "unknown"); // Missing section
}
}

0 comments on commit bb787ba

Please sign in to comment.