Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows
test: remove 24 duplicate unit tests (#629)
Maximilian Roos43b8648beb32
diff --git a/src/config/mod.rs b/src/config/mod.rsindex 1689de67e..0da85fb9f 100644--- a/src/config/mod.rs+++ b/src/config/mod.rs@@ -214,15 +214,6 @@ mod tests {);}- #[test]- fn test_project_config_default() {- let config = ProjectConfig::default();- assert!(config.hooks.post_create.is_none());- assert!(config.hooks.post_start.is_none());- assert!(config.hooks.pre_merge.is_none());- assert!(config.hooks.post_merge.is_none());- }-#[test]fn test_command_config_single() {let toml = r#"post-create = "npm install""#;diff --git a/src/config/project.rs b/src/config/project.rsindex ac5a22e7b..7b16c0ef8 100644--- a/src/config/project.rs+++ b/src/config/project.rs@@ -399,14 +399,6 @@ post-create = "npm install"assert!(keys.contains(&"baz".to_string()));}- #[test]- fn test_find_unknown_keys_invalid_toml() {- let contents = "invalid { toml }}}";- let keys = find_unknown_keys(contents);- // Returns empty vec for invalid TOML (graceful fallback)- assert!(keys.is_empty());- }-// ============================================================================// Serialization Tests// ============================================================================diff --git a/src/config/user.rs b/src/config/user.rsindex f597d91e9..0ab1f7deb 100644--- a/src/config/user.rs+++ b/src/config/user.rs@@ -826,14 +826,6 @@ another-unknown = 42assert!(keys.contains(&"another-unknown".to_string()));}- #[test]- fn test_find_unknown_keys_invalid_toml() {- // Invalid TOML should return empty- let content = "this is not valid toml {{{";- let keys = find_unknown_keys(content);- assert!(keys.is_empty());- }-#[test]fn test_find_unknown_keys_known_sections() {// All known sections should not be reporteddiff --git a/src/git/error.rs b/src/git/error.rsindex 586454792..ece1cbae6 100644--- a/src/git/error.rs+++ b/src/git/error.rs@@ -725,27 +725,6 @@ mod tests {use super::*;use insta::assert_snapshot;- #[test]- fn snapshot_detached_head_display() {- let err = GitError::DetachedHead { action: None };- assert_snapshot!(err.to_string(), @"- [31m✗[39m [31mNot on a branch (detached HEAD)[39m- [2m↳[22m [2mTo switch to a branch, run [90mgit switch <branch>[39m[22m- ");- }-- #[test]- fn snapshot_uncommitted_with_worktree_display() {- let err = GitError::UncommittedChanges {- action: Some("merge".into()),- branch: Some("wt".into()),- };- assert_snapshot!(err.to_string(), @"- [31m✗[39m [31mCannot merge: [1mwt[22m has uncommitted changes[39m- [2m↳[22m [2mCommit or stash changes first[22m- ");- }-#[test]fn snapshot_into_preserves_type_for_display() {// .into() preserves type so we can downcast and use Display@@ -775,19 +754,6 @@ mod tests {}}- #[test]- fn snapshot_worktree_error_with_path() {- let err = GitError::WorktreePathExists {- branch: "feature".to_string(),- path: PathBuf::from("/some/path"),- create: false,- };- assert_snapshot!(err.to_string(), @"- [31m✗[39m [31mDirectory already exists: [1m/some/path[22m[39m- [2m↳[22m [2mTo remove manually, run [90mrm -rf /some/path[39m; to overwrite (with backup), run [90mwt switch feature --clobber[39m[22m- ");- }-#[test]fn snapshot_worktree_error_with_path_and_create() {let err = GitError::WorktreePathExists {@@ -925,17 +891,6 @@ mod tests {);}- #[test]- fn test_git_error_invalid_reference() {- let err = GitError::InvalidReference {- reference: "nonexistent".into(),- };- let display = err.to_string();- assert!(display.contains("nonexistent"));- assert!(display.contains("not found"));- assert!(display.contains("--create"));- }-#[test]fn test_git_error_not_in_worktree() {// With action@@ -953,38 +908,6 @@ mod tests {assert!(display.contains("Not in a worktree"));}- #[test]- fn test_git_error_worktree_missing() {- let err = GitError::WorktreeMissing {- branch: "feature".into(),- };- let display = err.to_string();- assert!(display.contains("feature"));- assert!(display.contains("missing"));- }-- #[test]- fn test_git_error_no_worktree_found() {- let err = GitError::NoWorktreeFound {- branch: "feature".into(),- };- let display = err.to_string();- assert!(display.contains("No worktree found"));- assert!(display.contains("feature"));- }-- #[test]- fn test_git_error_remote_only_branch() {- let err = GitError::RemoteOnlyBranch {- branch: "feature".into(),- remote: "origin".into(),- };- let display = err.to_string();- assert!(display.contains("feature"));- assert!(display.contains("remote"));- assert!(display.contains("origin"));- }-#[test]fn test_git_error_worktree_path_occupied() {// With occupant branch@@ -1036,25 +959,6 @@ mod tests {assert!(display.contains("feature"));}- #[test]- fn test_git_error_worktree_removal_failed() {- let err = GitError::WorktreeRemovalFailed {- branch: "feature".into(),- path: PathBuf::from("/tmp/repo"),- error: "still has changes".into(),- };- let display = err.to_string();- assert!(display.contains("feature"));- assert!(display.contains("still has changes"));- }-- #[test]- fn test_git_error_cannot_remove_main() {- let err = GitError::CannotRemoveMainWorktree;- let display = err.to_string();- assert!(display.contains("main worktree"));- }-#[test]fn test_git_error_worktree_locked_with_reason() {let err = GitError::WorktreeLocked {@@ -1089,62 +993,6 @@ mod tests {assert!(display.contains("git worktree unlock /tmp/repo.feature"));}- #[test]- fn test_git_error_conflicting_changes() {- let err = GitError::ConflictingChanges {- target_branch: "main".into(),- files: vec!["file1.rs".into(), "file2.rs".into()],- worktree_path: PathBuf::from("/tmp/repo"),- };- let display = err.to_string();- assert!(display.contains("push to local"));- assert!(display.contains("main"));- assert!(display.contains("conflicting"));- assert!(display.contains("file1.rs"));- }-- #[test]- fn test_git_error_not_fast_forward() {- // In merge context- let err = GitError::NotFastForward {- target_branch: "main".into(),- commits_formatted: "abc1234 Some commit".into(),- in_merge_context: true,- };- let display = err.to_string();- assert!(display.contains("main"));- assert!(display.contains("wt merge"));-- // Not in merge context- let err = GitError::NotFastForward {- target_branch: "main".into(),- commits_formatted: String::new(),- in_merge_context: false,- };- let display = err.to_string();- assert!(display.contains("wt step rebase"));- }-- #[test]- fn test_git_error_rebase_conflict() {- // With git output- let err = GitError::RebaseConflict {- target_branch: "main".into(),- git_output: "CONFLICT in file.rs".into(),- };- let display = err.to_string();- assert!(display.contains("main"));- assert!(display.contains("CONFLICT"));-- // Without git output- let err = GitError::RebaseConflict {- target_branch: "main".into(),- git_output: String::new(),- };- let display = err.to_string();- assert!(display.contains("rebase --continue"));- }-#[test]fn test_git_error_not_rebased() {let err = GitError::NotRebased {@@ -1155,26 +1003,6 @@ mod tests {assert!(display.contains("not rebased"));}- #[test]- fn test_git_error_push_failed() {- let err = GitError::PushFailed {- target_branch: "main".into(),- error: "rejected".into(),- };- let display = err.to_string();- assert!(display.contains("push to local"));- assert!(display.contains("main"));- assert!(display.contains("rejected"));- }-- #[test]- fn test_git_error_not_interactive() {- let err = GitError::NotInteractive;- let display = err.to_string();- assert!(display.contains("non-interactive"));- assert!(display.contains("--yes"));- }-#[test]fn test_git_error_hook_command_not_found() {// With available commands@@ -1217,44 +1045,6 @@ mod tests {assert!(display.contains("llm --model gpt-4"));}- #[test]- fn test_git_error_project_config_not_found() {- let err = GitError::ProjectConfigNotFound {- config_path: PathBuf::from("/.worktrunk.toml"),- };- let display = err.to_string();- assert!(display.contains("No project configuration"));- assert!(display.contains(".worktrunk.toml"));- }-- #[test]- fn test_git_error_parse_error() {- let err = GitError::ParseError {- message: "invalid syntax".into(),- };- let display = err.to_string();- assert!(display.contains("invalid syntax"));- }-- #[test]- fn test_git_error_other() {- let err = GitError::Other {- message: "something went wrong".into(),- };- let display = err.to_string();- assert!(display.contains("something went wrong"));- }-- #[test]- fn test_git_error_detached_head_with_action() {- let err = GitError::DetachedHead {- action: Some("merge".into()),- };- let display = err.to_string();- assert!(display.contains("Cannot merge"));- assert!(display.contains("detached HEAD"));- }-#[test]fn test_git_error_uncommitted_changes_variants() {// Action onlydiff --git a/src/styling/mod.rs b/src/styling/mod.rsindex 769917db6..e71b83589 100644--- a/src/styling/mod.rs+++ b/src/styling/mod.rs@@ -283,31 +283,6 @@ command = "npm install"assert!(rejoined.contains("🎉"));}- #[test]- fn test_format_with_gutter_wrapping() {- // Create a very long line that would overflow a narrow terminal- let long_text = "This is a very long commit message that would normally overflow the terminal width and break the gutter formatting, but now it should wrap nicely at word boundaries.";-- // Use fixed width for consistent testing (80 columns)- let result = format_with_gutter(long_text, Some(80));-- // Should contain multiple lines (wrapped)- let line_count = result.lines().count();- assert!(- line_count > 1,- "Long text should wrap to multiple lines, got {} lines",- line_count- );-- // Each line should have the gutter- for line in result.lines() {- assert!(- line.contains("\x1b[107m"),- "Each line should contain gutter (BrightWhite background)"- );- }- }-#[test]fn test_format_with_gutter_preserves_newlines() {let multi_line = "Line 1\nLine 2\nLine 3";@@ -445,12 +420,6 @@ command = "npm install"assert_eq!(result, vec!["short line"]);}- #[test]- fn test_wrap_styled_text_zero_width() {- let result = wrap_styled_text("some text", 0);- assert_eq!(result, vec!["some text"]);- }-#[test]fn test_wrap_styled_text_at_word_boundary() {let text = "This is a very long line that needs wrapping";@@ -488,12 +457,6 @@ command = "npm install");}- #[test]- fn test_wrap_styled_text_empty_input() {- let result = wrap_styled_text("", 50);- assert_eq!(result, vec![""]);- }-#[test]fn test_wrap_styled_text_single_long_word() {// A single word longer than max_width should still be included