Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fix flaky FilesTest #1546

Merged
merged 2 commits into from
Jan 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion buildSrc/src/main/kotlin/Versions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ object Versions {
// https://github.com/getsentry/sentry-java/releases
const val SENTRY = "3.2.1"

//https://github.com/mixpanel/mixpanel-java/releases
// https://github.com/mixpanel/mixpanel-java/releases
const val MIXPANEL = "1.5.0"

// https://github.com/3breadt/dd-plist/releases
Expand Down
2 changes: 1 addition & 1 deletion flank-scripts/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ shadowJar.apply {
}
}
// <breaking change>.<feature added>.<fix/minor change>
version = "1.4.5"
version = "1.4.6"
group = "com.github.flank"

application {
Expand Down
26 changes: 8 additions & 18 deletions flank-scripts/src/test/kotlin/flank/common/FilesTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,23 @@ package flank.common

import org.junit.Assert
import org.junit.Assume
import org.junit.Rule
import org.junit.Test
import java.io.File
import org.junit.rules.TemporaryFolder
import java.nio.file.Files
import java.nio.file.Paths

internal class FilesTest {

@get:Rule
val root = TemporaryFolder()

@Test
fun `Should create symbolic file at desired location`() {
Assume.assumeFalse(isWindows)
// given
val testFile = File.createTempFile("test", "file").toPath()
val expectedDestination = Paths.get(Files.createTempDirectory("temp").toString(), "test.link")
val testFile = root.newFile("test.file").toPath()
val expectedDestination = Paths.get(root.newFolder("temp").toString(), "test.link")

// when
createSymbolicLinkToFile(expectedDestination, testFile)
Expand All @@ -27,24 +31,10 @@ internal class FilesTest {
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
downloadFile(testSource, testDestination)

// then
Assert.assertTrue(testDestination.toFile().exists())
Assert.assertTrue(testDestination.toFile().length() > 0)
}

@Test
fun `Should check if directory contains all needed files`() {
// given
val testDirectory = Files.createTempDirectory("test")
val testDirectory = root.newFolder("test").toPath()
val testFiles = listOf(
Paths.get(testDirectory.toString(), "testFile1"),
Paths.get(testDirectory.toString(), "testFile2"),
Expand Down