Skip to content

Commit

Permalink
Merge pull request #23 from Ferlab-Ste-Justine/feat/clin-2719-more-ex…
Browse files Browse the repository at this point in the history
…plicit-confirmation

feat: CLIN-2719 confirm download
  • Loading branch information
creativeyann17 authored Apr 10, 2024
2 parents 27de5d9 + 07f3610 commit 13de04e
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 4 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: build and test

on:
push:
branches: [ main ]
branches: [ main, clin-v1.4.x ]
pull_request:
branches: [ main ]
branches: [ main, clin-v1.4.x ]

jobs:
build_and_test:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ class Download(userConfig: UserConfig,
s"$totalExpectedDownloadSizeStr do you want to continue (your available disk space is: $usableSPaceStr) ? [$downloadAgreement]")
println()

if (agreedToDownload.equals(downloadAgreement) || StringUtils.isBlank(agreedToDownload)) {
if (downloadAgreement.startsWith(agreedToDownload) || StringUtils.isBlank(agreedToDownload)) {

if (usableSpace < totalExpectedDownloadSize) {
throw new IllegalStateException(s"Not enough disk space available $usableSpace < $totalExpectedDownloadSize")
Expand All @@ -127,6 +127,8 @@ class Download(userConfig: UserConfig,

println(s"Total downloaded files: ${files.size} located here: ${outputDir.getAbsolutePath}")
println()
} else {
throw new IllegalStateException(s"Aborted by user")
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@ class DownloadTest extends AnyFunSuite with BeforeAndAfter {

override def readPassword(fmt: String): String = "bar"
}

val mockCommandLineInfAgreedSimple: ICommandLine = new ICommandLine {
override def readLine(fmt: String): String = "y"

override def readPassword(fmt: String): String = "bar"
}

val mockCommandLineInfNotAgreed: ICommandLine = new ICommandLine {
override def readLine(fmt: String): String = "no"

Expand Down Expand Up @@ -143,7 +150,7 @@ class DownloadTest extends AnyFunSuite with BeforeAndAfter {
}

val cmd = new CommandLine(new Download(mockUserConfig, appTestConfig, mockCommandLineInfNotAgreed, mockKeycloakInf, mockFerload, mockS3))
assert(cmd.execute("-m", manifestValidFile) == 1)
assertCommandException(cmd, "Aborted by user", "-m", manifestValidFile)
}

test("not enough disk space") {
Expand Down Expand Up @@ -180,4 +187,21 @@ class DownloadTest extends AnyFunSuite with BeforeAndAfter {
assert(cmd.execute("-m", manifestValidFile) == 1)
}

test("confirm download simplified") {

val mockS3: IS3 = new IS3 {
override def download(outputDir: File, links: Map[String, String]): Set[File] = {
assert(links.size == 2)
Set(new File("f1"), new File("f2"))
}

override def getTotalExpectedDownloadSize(links: Map[String, String], timeout: Long): Long = 1L

override def getTotalAvailableDiskSpaceAt(manifest: File): Long = 2L
}

val cmd = new CommandLine(new Download(mockUserConfig, appTestConfig, mockCommandLineInfAgreedSimple, mockKeycloakValidTokenInf, mockFerload, mockS3))
assert(cmd.execute("-m", manifestValidFile) == 1)
}

}

0 comments on commit 13de04e

Please sign in to comment.