Skip to content

Commit

Permalink
test: add integration tests for diff mode
Browse files Browse the repository at this point in the history
  • Loading branch information
jpedroh committed Jun 15, 2024
1 parent bea2ba5 commit fdb6c62
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 1 deletion.
2 changes: 1 addition & 1 deletion bin/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ mod cli_exit_codes;
mod control;

pub use cli_exit_codes::*;
pub use control::{run_tool_on_merge_scenario,run_diff_on_files};
pub use control::{run_diff_on_files, run_tool_on_merge_scenario};
22 changes: 22 additions & 0 deletions bin/tests/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,25 @@ fn if_there_is_no_conflict_it_returns_valid_exit_code() {
.assert()
.code(bin::SUCCESS_WITHOUT_CONFLICTS);
}

#[test]
fn if_i_am_running_on_diff_mode_and_files_fully_match_it_returns_zero() {
let mut cmd = Command::cargo_bin("generic-merge").unwrap();
cmd.arg("--diff-only")
.arg("--left-path=tests/diff_scenarios/java_files_full_match/left.java")
.arg("--right-path=tests/diff_scenarios/java_files_full_match/right.java")
.arg("--language=java")
.assert()
.code(bin::SUCCESS_FILES_FULLY_MATCH);
}

#[test]
fn if_i_am_running_on_diff_mode_and_files_do_not_fully_match_it_returns_one() {
let mut cmd = Command::cargo_bin("generic-merge").unwrap();
cmd.arg("--diff-only")
.arg("--left-path=tests/diff_scenarios/java_files_not_fully_matching/left.java")
.arg("--right-path=tests/diff_scenarios/java_files_not_fully_matching/right.java")
.arg("--language=java")
.assert()
.code(bin::SUCCESS_FILES_DO_NOT_FULLY_MATCH);
}
11 changes: 11 additions & 0 deletions bin/tests/diff_scenarios/java_files_full_match/left.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
public class Main {
static {
int x = 2;
}

public static void main() {
int a = 0;
}

public static void teste() {}
}
11 changes: 11 additions & 0 deletions bin/tests/diff_scenarios/java_files_full_match/right.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
public class Main {
static {
int x = 2;
}

public static void teste() {}

public static void main() {
int a = 0;
}
}
11 changes: 11 additions & 0 deletions bin/tests/diff_scenarios/java_files_not_fully_matching/left.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
public class Main {
static {
int x = 2;
}

public static void main() {
int a = 2;
}

public static void teste() {}
}
11 changes: 11 additions & 0 deletions bin/tests/diff_scenarios/java_files_not_fully_matching/right.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
public class Main {
static {
int x = 2;
}

public static void teste() {}

public static void main() {
int a = 0;
}
}

0 comments on commit fdb6c62

Please sign in to comment.