-
Notifications
You must be signed in to change notification settings - Fork 118
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Piotr Adamczyk
committed
Dec 11, 2020
1 parent
93f9cbd
commit 6f53eb2
Showing
2 changed files
with
114 additions
and
0 deletions.
There are no files selected for viewing
43 changes: 43 additions & 0 deletions
43
test_runner/src/test/kotlin/ftl/ios/xctest/common/InstallParseBinariesTest.kt
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,43 @@ | ||
package ftl.ios.xctest.common | ||
|
||
import ftl.config.FtlConstants | ||
import ftl.util.hasAllFiles | ||
import org.junit.Assert.assertTrue | ||
import org.junit.Assume.assumeTrue | ||
import org.junit.Test | ||
import java.nio.file.Paths | ||
|
||
internal class InstallParseBinariesTest { | ||
|
||
@Test | ||
fun `should install binaries for windows`() { | ||
// given | ||
assumeTrue(FtlConstants.isWindows) | ||
|
||
// when | ||
installBinaries | ||
|
||
// then | ||
assertTrue( | ||
Paths.get(FtlConstants.userHome, ".flank").toFile().hasAllFiles( | ||
listOf("libatomic.so.1", "libatomic.so.1.2.0") | ||
) | ||
) | ||
} | ||
|
||
@Test | ||
fun `should install binaries for linux`() { | ||
// given | ||
assumeTrue(FtlConstants.isWindows.not() && FtlConstants.isMacOS.not()) | ||
|
||
// when | ||
installBinaries | ||
|
||
// then | ||
assertTrue( | ||
Paths.get(FtlConstants.userHome, ".flank").toFile().hasAllFiles( | ||
listOf("nm", "swift-demangle", "libatomic.so.1", "libatomic.so.1.2.0") | ||
) | ||
) | ||
} | ||
} |
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,71 @@ | ||
package ftl.util | ||
|
||
import org.junit.Assert.assertFalse | ||
import org.junit.Assert.assertTrue | ||
import org.junit.Test | ||
import java.io.File | ||
import java.nio.file.Files | ||
import java.nio.file.Paths | ||
|
||
internal class FilesTest { | ||
|
||
@Test | ||
fun `Should create symbolic file at desired location`() { | ||
// given | ||
val testFile = File.createTempFile("test", "file").toPath() | ||
val expectedDestination = Paths.get(Files.createTempDirectory("temp").toString(), "test.link") | ||
|
||
// when | ||
createSymbolicLink(expectedDestination, testFile) | ||
|
||
// then | ||
assertTrue(Files.isSymbolicLink(expectedDestination)) | ||
|
||
// clean | ||
testFile.toFile().delete() | ||
expectedDestination.toFile().delete() | ||
} | ||
|
||
@Test | ||
fun `Should download file and store it and destination`() { | ||
// given | ||
val testSource = "https://github.com/Flank/flank/blob/master/settings.gradle.kts" | ||
val testDestination = Paths.get(Files.createTempDirectory("temp").toString(), "settings.gradle.kts") | ||
|
||
// when | ||
download(testSource, testDestination) | ||
|
||
// then | ||
assertTrue(testDestination.toFile().exists()) | ||
assertTrue(testDestination.toFile().length() > 0) | ||
} | ||
|
||
@Test | ||
fun `Should check if directory contains all needed files`() { | ||
// given | ||
val testDirectory = Files.createTempDirectory("test") | ||
val testFiles = listOf( | ||
Paths.get(testDirectory.toString(), "testFile1"), | ||
Paths.get(testDirectory.toString(), "testFile2"), | ||
Paths.get(testDirectory.toString(), "testFile3"), | ||
Paths.get(testDirectory.toString(), "testFile4") | ||
) | ||
|
||
testFiles.forEach { Files.createFile(it) } | ||
|
||
// when | ||
val resultTrue = testDirectory.toFile().hasAllFiles(testFiles.map { it.fileName.toString() }) | ||
val resultFalse = testDirectory.toFile() | ||
.hasAllFiles( | ||
(testFiles + Paths.get(testDirectory.toString(), "testFile5")) | ||
.map { it.fileName.toString() } | ||
) | ||
|
||
// then | ||
assertTrue(resultTrue) | ||
assertFalse(resultFalse) | ||
|
||
// clean | ||
testDirectory.toFile().deleteRecursively() | ||
} | ||
} |