-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Test Cases for CommandExecutor
Updated kotlin_lint.yml Fixed Lint Errors
- Loading branch information
1 parent
ee1dc9e
commit 4dbaaf2
Showing
13 changed files
with
88 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ name: kotlin_lint | |
|
||
on: | ||
push: | ||
branches: | ||
branches-ignore: | ||
- "*" | ||
pull_request: | ||
paths: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,5 +22,4 @@ object FileDialogType { | |
object SigningMode { | ||
const val DEBUG = 1 | ||
const val RELEASE = 2 | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,10 @@ | ||
package utils | ||
|
||
import java.util.* | ||
import java.util.Locale | ||
|
||
object Utils { | ||
|
||
fun isWindowsOS(): Boolean{ | ||
fun isWindowsOS(): Boolean { | ||
return System.getProperty("os.name").lowercase(Locale.getDefault()).contains("windows") | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package command | ||
|
||
import junit.framework.TestCase.assertTrue | ||
import kotlinx.coroutines.runBlocking | ||
import org.hamcrest.MatcherAssert.assertThat | ||
import org.junit.Before | ||
import org.junit.Test | ||
|
||
class CommandExecutorTest { | ||
private lateinit var commandExecutor: CommandExecutor | ||
|
||
@Before | ||
fun setUp() { | ||
commandExecutor = CommandExecutor() | ||
} | ||
|
||
// These test cases may not work for MAC and Linux need to verify. | ||
@Test | ||
fun `execute valid command successfully`() { | ||
val expectedOutput = "openjdk 11.0.18 2023-01-17" | ||
val cmd = "java --version" | ||
|
||
runBlocking { | ||
commandExecutor.executeCommand( | ||
cmd, | ||
this, | ||
onSuccess = { | ||
println("SUCCESS -> $it") | ||
assertThat(expectedOutput, it.contains(expectedOutput)) | ||
}, | ||
onFailure = { | ||
println("ERROR -> ${it.message}") | ||
assertThat(expectedOutput, it.message?.contains(expectedOutput) ?: false) | ||
} | ||
) | ||
} | ||
} | ||
|
||
@Test | ||
fun `execute invalid command and handle failure`() { | ||
val cmd = "invalid_command" | ||
runBlocking { | ||
commandExecutor.executeCommand( | ||
cmd, | ||
this, | ||
onSuccess = { | ||
assertTrue(it.isEmpty()) | ||
}, | ||
onFailure = { | ||
assertTrue(it.message?.contains("The system cannot find the file specified") ?: false) | ||
} | ||
) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters