Skip to content

Commit

Permalink
#3745 add Unit Tests
Browse files Browse the repository at this point in the history
  • Loading branch information
VictoriaG committed Oct 1, 2024
1 parent e0855e0 commit aff1fa6
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -108,14 +108,16 @@ class MergeFilter(
}
}

if (!hasTopLevelOverlap(rootChildrenNodes)) {
printOverlapError(rootChildrenNodes)
if (!mergeModules) {
if (!hasTopLevelOverlap(rootChildrenNodes)) {
printOverlapError(rootChildrenNodes)

val continueMerge = ParserDialog.askForceMerge()
val continueMerge = ParserDialog.askForceMerge()

if (!continueMerge) {
Logger.info { "Merge cancelled by the user." }
return null
if (!continueMerge) {
Logger.info { "Merge cancelled by the user." }
return null
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,4 +170,24 @@ class MergeFilterTest {

assertThat(errContent.toString()).contains("Input invalid files/folders for MergeFilter, stopping execution...")
}

@Test
fun `should log error when no cc json files found in the folder`() {
System.setErr(PrintStream(errContent))

CommandLine(MergeFilter()).execute("src/test/resources/noCCJsonFiles")

System.setErr(originalErr)
assertThat(errContent.toString()).contains("Input invalid files/folders for MergeFilter, stopping execution...")
}

@Test
fun `should log error when folder path is invalid`() {
System.setErr(PrintStream(errContent))

CommandLine(MergeFilter()).execute("invalid/path/to/folder")

System.setErr(originalErr)
assertThat(errContent.toString()).contains("Input invalid files/folders for MergeFilter, stopping execution...")
}
}

0 comments on commit aff1fa6

Please sign in to comment.