How to use Exhaustive.Companion.lines method of io.kotest.property.exhaustive.file class

Best Kotest code snippet using io.kotest.property.exhaustive.file.Exhaustive.Companion.lines

WhenDownloadingAwsDeviceFarmArtifacts.kt

Source:WhenDownloadingAwsDeviceFarmArtifacts.kt Github

copy

Full Screen

1package io.github.ricardorlg.devicefarm.tractor.controller2import arrow.core.Either3import io.github.ricardorlg.devicefarm.tractor.model.*4import io.github.ricardorlg.devicefarm.tractor.stubs.*5import io.github.ricardorlg.devicefarm.tractor.tempFolder6import io.github.ricardorlg.devicefarm.tractor.utils.prettyName7import io.kotest.assertions.arrow.core.shouldBeLeft8import io.kotest.assertions.arrow.core.shouldBeRight9import io.kotest.assertions.fail10import io.kotest.assertions.withClue11import io.kotest.core.spec.style.StringSpec12import io.kotest.engine.spec.tempfile13import io.kotest.extensions.system.captureStandardOut14import io.kotest.inspectors.forAll15import io.kotest.matchers.collections.shouldContainExactlyInAnyOrder16import io.kotest.matchers.paths.shouldBeADirectory17import io.kotest.matchers.paths.shouldContainFile18import io.kotest.matchers.paths.shouldContainNFiles19import io.kotest.matchers.paths.shouldNotContainFile20import io.kotest.matchers.should21import io.kotest.matchers.shouldBe22import io.kotest.matchers.string.shouldStartWith23import io.kotest.matchers.throwable.shouldHaveMessage24import io.kotest.matchers.types.shouldBeInstanceOf25import io.kotest.property.Exhaustive26import io.kotest.property.checkAll27import io.kotest.property.exhaustive.collection28import software.amazon.awssdk.services.devicefarm.model.Artifact29import software.amazon.awssdk.services.devicefarm.model.ArtifactType30import software.amazon.awssdk.services.devicefarm.model.Job31import software.amazon.awssdk.services.devicefarm.model.Run32import java.nio.file.AccessDeniedException33import java.nio.file.Paths34import java.nio.file.attribute.PosixFilePermissions35import kotlin.io.path.createDirectory36import kotlin.io.path.listDirectoryEntries37import kotlin.time.Duration38import kotlin.time.Duration.Companion.milliseconds39class WhenDownloadingAwsDeviceFarmArtifacts : StringSpec({40 val logger = MockedDeviceFarmLogging()41 val deviceFarmProjectsHandler = MockedDeviceFarmProjectsHandler()42 val devicePoolsHandler = MockedDeviceFarmDevicePoolsHandler()43 val uploadArtifactsHandler = MockedDeviceFarmUploadArtifactsHandler()44 val runScheduleHandler = MockedDeviceFarmRunsHandler()45 val commonArtifactsHandler = MockedDeviceFarmArtifactsHandler()46 val deviceName = "nexus 3"47 val artifactType = ArtifactType.CUSTOMER_ARTIFACT48 val downloadableTypes = listOf(ArtifactType.CUSTOMER_ARTIFACT, ArtifactType.VIDEO)49 val validTypes =50 ArtifactType.values().filter { it != ArtifactType.UNKNOWN && it != ArtifactType.UNKNOWN_TO_SDK_VERSION }51 "It should use a pretty name when the artifact type is video or customer artifact"{52 checkAll(Exhaustive.collection(ArtifactType.values().asList())) { type ->53 when (type) {54 ArtifactType.VIDEO -> type.prettyName() shouldBe "Recorded video"55 ArtifactType.CUSTOMER_ARTIFACT -> type.prettyName() shouldBe "Test reports"56 else -> type.prettyName() shouldBe type.name57 }58 }59 }60 "It should return a DeviceFarmTractorErrorIllegalArgumentException if the searched artifact type is not supported"{61 checkAll(Exhaustive.collection(INVALID_ARTIFACT_TYPES)) { type ->62 //GIVEN63 val customerArtifact = tempfile("test_downloadable_${type.name.lowercase()}_", ".zip")64 val destinyFolder = tempFolder("testReports")65 val artifact = Artifact66 .builder()67 .arn("arn:test:artifact")68 .name(customerArtifact.nameWithoutExtension)69 .extension(customerArtifact.extension)70 .type(artifactType)71 .url(customerArtifact.toURI().toASCIIString())72 .build()73 //WHEN74 val response = DefaultDeviceFarmTractorController(75 logger,76 deviceFarmProjectsHandler,77 devicePoolsHandler,78 uploadArtifactsHandler,79 runScheduleHandler,80 commonArtifactsHandler81 ).downloadAWSDeviceFarmArtifacts(82 artifacts = listOf(artifact),83 deviceName = deviceName,84 path = destinyFolder,85 artifactType = type86 )87 //THEN88 response.shouldBeLeft() should {89 it.shouldBeInstanceOf<DeviceFarmTractorErrorIllegalArgumentException>()90 it shouldHaveMessage "$type is not supported"91 }92 destinyFolder shouldNotContainFile customerArtifact.name93 destinyFolder shouldContainNFiles 094 }95 }96 "It should download an AWS Device farm artifact of a job execution depending of its type"{97 checkAll(Exhaustive.collection(validTypes)) { type ->98 //GIVEN99 val customerArtifact = tempfile("test_downloadable_${type.name.lowercase()}_", ".zip")100 val destinyFolder = tempFolder("testReports")101 val artifact = Artifact102 .builder()103 .arn("arn:test:artifact")104 .name(customerArtifact.nameWithoutExtension)105 .extension(customerArtifact.extension)106 .type(type)107 .url(customerArtifact.toURI().toASCIIString())108 .build()109 //WHEN110 val response = DefaultDeviceFarmTractorController(111 logger,112 deviceFarmProjectsHandler,113 devicePoolsHandler,114 uploadArtifactsHandler,115 runScheduleHandler,116 commonArtifactsHandler117 ).downloadAWSDeviceFarmArtifacts(118 artifacts = listOf(artifact),119 deviceName = deviceName,120 path = destinyFolder,121 artifactType = type122 )123 //THEN124 response.shouldBeRight()125 destinyFolder shouldContainFile customerArtifact.name126 destinyFolder shouldContainNFiles 1127 }128 }129 "It should log a message when the searched artifact type is not found in the job artifacts"{130 checkAll(Exhaustive.collection(validTypes)) { type ->131 //GIVEN132 val customerArtifact = tempfile("test_downloadable_${type.name.lowercase()}_", ".zip")133 val destinyFolder = tempFolder("testReports")134 val artifact = Artifact135 .builder()136 .arn("arn:test:artifact")137 .name(customerArtifact.nameWithoutExtension)138 .extension(customerArtifact.extension)139 .type(ArtifactType.UNKNOWN)140 .url(customerArtifact.toURI().toASCIIString())141 .build()142 val expectedLoggedMessage = JOB_DOES_NOT_HAVE_ARTIFACT_OF_TYPE.format(143 type.name,144 deviceName145 )146 //WHEN147 val loggedMessage = captureStandardOut {148 DefaultDeviceFarmTractorController(149 MockedDeviceFarmLogging(true),150 deviceFarmProjectsHandler,151 devicePoolsHandler,152 uploadArtifactsHandler,153 runScheduleHandler,154 commonArtifactsHandler155 ).downloadAWSDeviceFarmArtifacts(156 artifacts = listOf(artifact),157 deviceName = deviceName,158 path = destinyFolder,159 artifactType = type160 ).shouldBeRight()161 }.lines()162 .filter(String::isNotBlank)163 .map(String::trim)164 .last()165 //THEN166 loggedMessage shouldBe expectedLoggedMessage167 destinyFolder shouldNotContainFile customerArtifact.name168 destinyFolder shouldContainNFiles 0169 }170 }171 "It should return an ErrorDownloadingArtifact when there is a problem saving the artifact on disk"{172 //GIVEN173 val onlyReadDestinyFolderPermission = PosixFilePermissions.fromString("r--r--r--")174 val customerArtifact = tempfile("test_downloadable", ".zip")175 val destinyFolder =176 tempFolder("testReports", PosixFilePermissions.asFileAttribute(onlyReadDestinyFolderPermission))177 val artifact = Artifact178 .builder()179 .arn("arn:test:artifact")180 .name(customerArtifact.nameWithoutExtension)181 .extension(customerArtifact.extension)182 .type(ArtifactType.CUSTOMER_ARTIFACT)183 .url(customerArtifact.toURI().toASCIIString())184 .build()185 //WHEN186 val response = DefaultDeviceFarmTractorController(187 logger,188 deviceFarmProjectsHandler,189 devicePoolsHandler,190 uploadArtifactsHandler,191 runScheduleHandler,192 commonArtifactsHandler193 ).downloadAWSDeviceFarmArtifacts(194 artifacts = listOf(artifact),195 deviceName = deviceName,196 path = destinyFolder,197 artifactType = artifactType198 )199 //THEN200 response.shouldBeLeft() should {201 it.shouldBeInstanceOf<ErrorDownloadingArtifact>()202 it.cause.shouldBeInstanceOf<AccessDeniedException>()203 }204 }205 "It should not fail if there is no artifacts to download"{206 //GIVEN207 val customerArtifact = tempfile("test_downloadable", ".zip")208 val destinyFolder = tempFolder("testReports")209 //WHEN210 val response = DefaultDeviceFarmTractorController(211 logger,212 deviceFarmProjectsHandler,213 devicePoolsHandler,214 uploadArtifactsHandler,215 runScheduleHandler,216 commonArtifactsHandler217 ).downloadAWSDeviceFarmArtifacts(218 artifacts = emptyList(),219 deviceName = deviceName,220 path = destinyFolder,221 artifactType = artifactType222 )223 //THEN224 response.shouldBeRight()225 destinyFolder shouldNotContainFile customerArtifact.name226 destinyFolder shouldContainNFiles 0227 }228 "It should download all the test reports and recorded videos associated to the test Run"{229 //GIVEN230 val customerArtifactFile = tempfile("test_downloadable", ".zip")231 val recordedVideoFile = tempfile("test_video", ".mp4")232 val destinyFolder = tempFolder("testReports")233 val run = Run234 .builder()235 .name("test run")236 .arn("arn:test:run")237 .build()238 val jobs = (1..10)239 .map { job ->240 Job241 .builder()242 .arn("arn:test:job:$job")243 .name("test job $job")244 .device {245 it.name("Test device $job")246 .arn("arn:test:device:$job")247 }.build()248 }249 val customerArtifact = Artifact250 .builder()251 .arn("arn:test:customer_artifact")252 .name(customerArtifactFile.nameWithoutExtension)253 .extension(customerArtifactFile.extension)254 .type(ArtifactType.CUSTOMER_ARTIFACT)255 .url(customerArtifactFile.toURI().toASCIIString())256 .build()257 val recordedVideoArtifact = Artifact258 .builder()259 .arn("arn:test:video_artifact")260 .name(recordedVideoFile.nameWithoutExtension)261 .extension(recordedVideoFile.extension)262 .type(ArtifactType.VIDEO)263 .url(recordedVideoFile.toURI().toASCIIString())264 .build()265 val downloadArtifactsHandler = MockedDeviceFarmArtifactsHandler(266 getArtifactsImpl = { Either.Right(listOf(customerArtifact, recordedVideoArtifact)) }267 )268 val runHandler = MockedDeviceFarmRunsHandler(269 getAssociatedJobsImpl = { Either.Right(jobs) }270 )271 val reportDirectoryPath = Paths.get("test_reports_${run.name().lowercase().replace("\\s".toRegex(), "_")}")272 //WHEN273 DefaultDeviceFarmTractorController(274 logger,275 deviceFarmProjectsHandler,276 devicePoolsHandler,277 uploadArtifactsHandler,278 runHandler,279 downloadArtifactsHandler280 ).downloadAllEvidencesOfTestRun(run, destinyFolder, 0.milliseconds)281 //THEN282 destinyFolder shouldContainFile reportDirectoryPath.toFile().name283 destinyFolder shouldContainNFiles 1284 destinyFolder.resolve(reportDirectoryPath).shouldBeADirectory()285 destinyFolder.resolve(reportDirectoryPath) shouldContainNFiles jobs.size286 destinyFolder.resolve(reportDirectoryPath).listDirectoryEntries().forAll {287 it.shouldBeADirectory()288 it shouldContainFile customerArtifactFile.name289 it shouldContainFile recordedVideoFile.name290 it shouldContainNFiles 2291 }292 }293 "It should log an error message when downloading a recorded video or test report fails"{294 checkAll(Exhaustive.collection(downloadableTypes)) { type ->295 //GIVEN296 val testFile = tempfile("test_downloadable_${type.name.lowercase()}", ".zip")297 val destinyFolder = tempFolder("testReports")298 val run = Run299 .builder()300 .name("test run")301 .arn("arn:test:run")302 .build()303 val job = Job304 .builder()305 .arn("arn:test:job")306 .name("test job")307 .device {308 it.name(deviceName)309 .arn("arn:test:device")310 }.build()311 val artifact = Artifact312 .builder()313 .arn("arn:test:artifact")314 .name(testFile.nameWithoutExtension)315 .extension(testFile.extension)316 .type(type)317 .url(testFile.toURI().toASCIIString())318 .build()319 val downloadArtifactsHandler = MockedDeviceFarmArtifactsHandler(320 getArtifactsImpl = { Either.Right(listOf(artifact)) }321 )322 val runHandler = MockedDeviceFarmRunsHandler(323 getAssociatedJobsImpl = { Either.Right(listOf(job)) }324 )325 val reportDirectoryPath =326 Paths.get("test_reports_${run.name().lowercase().replace("\\s".toRegex(), "_")}")327 testFile.setReadable(false)328 //WHEN329 val loggedMessages = captureStandardOut {330 DefaultDeviceFarmTractorController(331 MockedDeviceFarmLogging(true),332 deviceFarmProjectsHandler,333 devicePoolsHandler,334 uploadArtifactsHandler,335 runHandler,336 downloadArtifactsHandler337 ).downloadAllEvidencesOfTestRun(run, destinyFolder, 0.milliseconds)338 }.lineSequence()339 .filter(String::isNotBlank)340 .map(String::trim)341 //THEN342 destinyFolder shouldContainNFiles 1343 destinyFolder shouldContainFile reportDirectoryPath.fileName.toString()344 destinyFolder.resolve(reportDirectoryPath).shouldBeADirectory()345 destinyFolder.resolve(reportDirectoryPath) shouldContainNFiles 0346 withClue("The logged messages should contain an error message related to the error downloading the artifact $type") {347 loggedMessages.any {348 it.startsWith(349 "There was an error downloading the ${350 type.prettyName()351 } of $deviceName test run."352 )353 }354 }355 }356 }357 "It should download all the reports even if any of them fails"{358 //GIVEN359 val expectedReports = (1..10)360 .map {361 tempfile("test_report_${it}_downloadable", ".zip")362 }363 val reportNotReadable = expectedReports.random()364 if (!reportNotReadable.setReadable(false)) fail("An error happens setting up the test")365 val destinyFolder = tempFolder("testReports")366 val run = Run367 .builder()368 .name("test run")369 .arn("arn:test:run")370 .build()371 val jobs = (1..10)372 .map { job ->373 Job374 .builder()375 .arn("arn:test:job:$job")376 .name("test job $job")377 .device {378 it.name("Test device $job")379 .arn("arn:test:device:$job")380 }.build()381 }382 val artifacts = expectedReports383 .mapIndexed { index, associatedReport ->384 Artifact385 .builder()386 .arn("arn:test:artifact:$index")387 .name(associatedReport.nameWithoutExtension)388 .extension(associatedReport.extension)389 .type(ArtifactType.CUSTOMER_ARTIFACT)390 .url(associatedReport.toURI().toASCIIString())391 .build()392 }393 val artifactsProvider = artifacts.iterator()394 val downloadArtifactsHandler = MockedDeviceFarmArtifactsHandler(395 getArtifactsImpl = {396 synchronized(this) {397 Either.Right(listOf(artifactsProvider.next()))398 }399 }400 )401 val runHandler = MockedDeviceFarmRunsHandler(402 getAssociatedJobsImpl = { Either.Right(jobs) }403 )404 val reportDirectoryPath = Paths.get("test_reports_${run.name().lowercase().replace("\\s".toRegex(), "_")}")405 //WHEN406 DefaultDeviceFarmTractorController(407 logger,408 deviceFarmProjectsHandler,409 devicePoolsHandler,410 uploadArtifactsHandler,411 runHandler,412 downloadArtifactsHandler413 ).downloadAllEvidencesOfTestRun(run, destinyFolder, 0.milliseconds)414 //THEN415 destinyFolder shouldContainFile reportDirectoryPath.fileName.toString()416 destinyFolder shouldContainNFiles 1417 destinyFolder.resolve(reportDirectoryPath).shouldBeADirectory()418 destinyFolder.resolve(reportDirectoryPath) shouldContainNFiles jobs.size - 1419 destinyFolder420 .resolve(reportDirectoryPath)421 .listDirectoryEntries()422 .flatMap {423 it.listDirectoryEntries()424 }425 .map { it.fileName }426 .shouldContainExactlyInAnyOrder(427 expectedReports428 .filter { it != reportNotReadable }429 .map { it.toPath().fileName }430 )431 }432 "It should download all the recorded videos even if any of them fails"{433 //GIVEN434 val expectedRecordedVideos = (1..10)435 .map {436 tempfile("recorde_video_${it}_downloadable", ".mp4")437 }438 val recordedVideoNotReadable = expectedRecordedVideos.random()439 if (!recordedVideoNotReadable.setReadable(false)) fail("An error happens setting up the test")440 val destinyFolder = tempFolder("testResults")441 val run = Run442 .builder()443 .name("test run")444 .arn("arn:test:run")445 .build()446 val jobs = (1..10)447 .map { job ->448 Job449 .builder()450 .arn("arn:test:job:$job")451 .name("test job $job")452 .device {453 it.name("Test device $job")454 .arn("arn:test:device:$job")455 }.build()456 }457 val artifacts = expectedRecordedVideos458 .mapIndexed { index, associatedVideo ->459 Artifact460 .builder()461 .arn("arn:test:artifact:$index")462 .name(associatedVideo.nameWithoutExtension)463 .extension(associatedVideo.extension)464 .type(ArtifactType.VIDEO)465 .url(associatedVideo.toURI().toASCIIString())466 .build()467 }468 val artifactsProvider = artifacts.iterator()469 val downloadArtifactsHandler = MockedDeviceFarmArtifactsHandler(470 getArtifactsImpl = {471 synchronized(this) {472 Either.Right(listOf(artifactsProvider.next()))473 }474 }475 )476 val runHandler = MockedDeviceFarmRunsHandler(477 getAssociatedJobsImpl = { Either.Right(jobs) }478 )479 val reportDirectoryPath = Paths.get("test_reports_${run.name().lowercase().replace("\\s".toRegex(), "_")}")480 //WHEN481 DefaultDeviceFarmTractorController(482 logger,483 deviceFarmProjectsHandler,484 devicePoolsHandler,485 uploadArtifactsHandler,486 runHandler,487 downloadArtifactsHandler488 ).downloadAllEvidencesOfTestRun(run, destinyFolder, 0.milliseconds)489 //THEN490 destinyFolder shouldContainFile reportDirectoryPath.fileName.toString()491 destinyFolder shouldContainNFiles 1492 destinyFolder.resolve(reportDirectoryPath).shouldBeADirectory()493 destinyFolder.resolve(reportDirectoryPath) shouldContainNFiles jobs.size - 1494 destinyFolder495 .resolve(reportDirectoryPath)496 .listDirectoryEntries()497 .flatMap {498 it.listDirectoryEntries()499 }500 .map { it.fileName }501 .shouldContainExactlyInAnyOrder(502 expectedRecordedVideos503 .filter { it != recordedVideoNotReadable }504 .map { it.toPath().fileName }505 )506 }507 "It should log an error message when creating the test report directory of an specific device fails"{508 //GIVEN509 val destinyFolder = tempFolder("testReports")510 val run = Run511 .builder()512 .name("test run")513 .arn("arn:test:run")514 .build()515 val job = Job516 .builder()517 .arn("arn:test:job")518 .name("test job")519 .device {520 it.name(deviceName)521 .arn("arn:test:device")522 }.build()523 val downloadArtifactsHandler = MockedDeviceFarmArtifactsHandler(524 getArtifactsImpl = { fail("This should never been called") }525 )526 val runHandler = MockedDeviceFarmRunsHandler(527 getAssociatedJobsImpl = { Either.Right(listOf(job)) }528 )529 val reportDirectoryPath = destinyFolder530 .resolve("test_reports_${run.name().lowercase().replace("\\s".toRegex(), "_")}")531 .createDirectory()532 //WHEN533 val lastOutput = captureStandardOut {534 DefaultDeviceFarmTractorController(535 MockedDeviceFarmLogging(true),536 deviceFarmProjectsHandler,537 devicePoolsHandler,538 uploadArtifactsHandler,539 runHandler,540 downloadArtifactsHandler541 ).downloadAllEvidencesOfTestRun(run, destinyFolder, 0.milliseconds)542 }.lineSequence()543 .filter(String::isNotBlank)544 .map(String::trim)545 .last()546 //THEN547 reportDirectoryPath shouldContainNFiles 0548 lastOutput shouldStartWith "There was a problem creating the folder ${reportDirectoryPath.fileName}"549 }550 "It should log an error message when creating the test reports directory fails"{551 //GIVEN552 val destinyFolder = tempFolder("testReports")553 val run = Run554 .builder()555 .name("test run")556 .arn("arn:test:run")557 .build()558 val job = Job559 .builder()560 .arn("arn:test:job")561 .name("test job")562 .device {563 it.name(deviceName)564 .arn("arn:test:device")565 }.build()566 val downloadArtifactsHandler = MockedDeviceFarmArtifactsHandler(567 getArtifactsImpl = { fail("This should never been called") }568 )569 val runHandler = MockedDeviceFarmRunsHandler(570 getAssociatedJobsImpl = { Either.Right(listOf(job)) }571 )572 val testReportsName = "test_reports_${run.name().lowercase().replace("\\s".toRegex(), "_")}"573 destinyFolder.toFile().setReadOnly()574 //WHEN575 val lastOutput = captureStandardOut {576 DefaultDeviceFarmTractorController(577 MockedDeviceFarmLogging(true),578 deviceFarmProjectsHandler,579 devicePoolsHandler,580 uploadArtifactsHandler,581 runHandler,582 downloadArtifactsHandler583 ).downloadAllEvidencesOfTestRun(run, destinyFolder, 0.milliseconds)584 }.lineSequence()585 .filter(String::isNotBlank)586 .map(String::trim)587 .last()588 //THEN589 destinyFolder shouldContainNFiles 0590 lastOutput shouldStartWith "There was a problem creating the folder $testReportsName"591 }592 "It should not try to download the reports when an error happens fetching the associated jobs of the test run"{593 //GIVEN594 val destinyFolder = tempFolder("testReports")595 val error = DeviceFarmTractorGeneralError(RuntimeException("test error"))596 val run = Run597 .builder()598 .name("test run")599 .arn("arn:test:run")600 .build()601 val downloadArtifactsHandler = MockedDeviceFarmArtifactsHandler(602 getArtifactsImpl = { fail("This should never been called") }603 )604 val runHandler = MockedDeviceFarmRunsHandler(605 getAssociatedJobsImpl = { Either.Left(error) }606 )607 //WHEN608 DefaultDeviceFarmTractorController(609 logger,610 deviceFarmProjectsHandler,611 devicePoolsHandler,612 uploadArtifactsHandler,613 runHandler,614 downloadArtifactsHandler615 ).downloadAllEvidencesOfTestRun(run, destinyFolder, 0.milliseconds)616 //THEN617 destinyFolder shouldContainNFiles 0618 }619 "It should download the recorded videos and test reports even if any of them fails"{620 //GIVEN621 val expectedReports = (1..10)622 .map {623 tempfile("test_report_${it}_downloadable", ".zip")624 }625 val expectedRecordedVideos = (1..10)626 .map {627 tempfile("test_video_${it}_downloadable", ".mp4")628 }629 val reportNotReadable = expectedReports.random()630 val videoNotReadable = expectedRecordedVideos.random()631 if (!reportNotReadable.setReadable(false)) fail("An error happens setting up the test")632 if (!videoNotReadable.setReadable(false)) fail("An error happens setting up the test")633 val destinyFolder = tempFolder("testReports")634 val run = Run635 .builder()636 .name("test run")637 .arn("arn:test:run")638 .build()639 val jobs = (1..10)640 .map { job ->641 Job642 .builder()643 .arn("arn:test:job:$job")644 .name("test job $job")645 .device {646 it.name("Test device $job")647 .arn("arn:test:device:$job")648 }.build()649 }650 val customerArtifacts = expectedReports651 .mapIndexed { index, associatedReport ->652 Artifact653 .builder()654 .arn("arn:test:customer_artifact:$index")655 .name(associatedReport.nameWithoutExtension)656 .extension(associatedReport.extension)657 .type(ArtifactType.CUSTOMER_ARTIFACT)658 .url(associatedReport.toURI().toASCIIString())659 .build()660 }661 val videoArtifacts = expectedRecordedVideos662 .mapIndexed { index, associatedVideo ->663 Artifact664 .builder()665 .arn("arn:test:video_artifact:$index")666 .name(associatedVideo.nameWithoutExtension)667 .extension(associatedVideo.extension)668 .type(ArtifactType.VIDEO)669 .url(associatedVideo.toURI().toASCIIString())670 .build()671 }672 val customerArtifactsProvider = customerArtifacts.iterator()673 val videoArtifactsProvider = videoArtifacts.iterator()674 val downloadArtifactsHandler = MockedDeviceFarmArtifactsHandler(675 getArtifactsImpl = {676 synchronized(this) {677 Either.Right(listOf(customerArtifactsProvider.next(), videoArtifactsProvider.next()))678 }679 }680 )681 val runHandler = MockedDeviceFarmRunsHandler(682 getAssociatedJobsImpl = { Either.Right(jobs) }683 )684 val reportDirectoryPath = Paths.get("test_reports_${run.name().lowercase().replace("\\s".toRegex(), "_")}")685 val expectedFiles = expectedReports686 .filter { it != reportNotReadable }687 .map { it.toPath().fileName } + expectedRecordedVideos688 .filter { it != videoNotReadable }689 .map { it.toPath().fileName }690 val expectedFilesSize =691 if (expectedReports.indexOf(reportNotReadable) == expectedRecordedVideos.indexOf(videoNotReadable)) jobs.size - 1 else jobs.size692 //WHEN693 DefaultDeviceFarmTractorController(694 logger,695 deviceFarmProjectsHandler,696 devicePoolsHandler,697 uploadArtifactsHandler,698 runHandler,699 downloadArtifactsHandler700 ).downloadAllEvidencesOfTestRun(run, destinyFolder, 0.milliseconds)701 //THEN702 destinyFolder shouldContainFile reportDirectoryPath.fileName.toString()703 destinyFolder shouldContainNFiles 1704 destinyFolder.resolve(reportDirectoryPath).shouldBeADirectory()705 destinyFolder.resolve(reportDirectoryPath) shouldContainNFiles expectedFilesSize706 destinyFolder707 .resolve(reportDirectoryPath)708 .listDirectoryEntries()709 .flatMap {710 it.listDirectoryEntries()711 }712 .map { it.fileName }713 .shouldContainExactlyInAnyOrder(expectedFiles)714 }715})...

Full Screen

Full Screen

file.kt

Source:file.kt Github

copy

Full Screen

1package io.kotest.property.exhaustive2import io.kotest.property.Exhaustive3import java.io.File4import java.nio.charset.Charset5import java.nio.file.Path6/**7 * Returns an [Exhaustive] that enumerates all the lines in the given file.8 */9fun Exhaustive.Companion.lines(file: File, charset: Charset = Charsets.UTF_8): Exhaustive<String> {10 val contents = file.readLines(charset)11 return exhaustive(contents)12}13/**14 * Returns an [Exhaustive] that enumerates all the lines in the given file.15 */16fun Exhaustive.Companion.lines(file: Path, charset: Charset = Charsets.UTF_8) = lines(file.toFile(), charset)...

Full Screen

Full Screen

Exhaustive.Companion.lines

Using AI Code Generation

copy

Full Screen

1import io.kotest.property.exhaustive.file2val lines = file.lines("file.txt")3import io.kotest.property.exhaustive.file4val lines = file.lines("file.txt")5import io.kotest.property.exhaustive.file6val lines = file.lines("file.txt")7import io.kotest.property.exhaustive.file8val lines = file.lines("file.txt")9import io.kotest.property.exhaustive.file10val lines = file.lines("file.txt")11import io.kotest.property.exhaustive.file12val lines = file.lines("file.txt")13import io.kotest.property.exhaustive.file14val lines = file.lines("file.txt")15import io.kotest.property.exhaustive.file16val lines = file.lines("file.txt")17import io.kotest.property.exhaustive.file18val lines = file.lines("file.txt")19import io.kotest.property.exhaustive.file20val lines = file.lines("file.txt")21import io.kotest.property.exhaustive.file22val lines = file.lines("file.txt")23import io.kotest.property.exhaustive.file24val lines = file.lines("file.txt")25import io.kotest.property

Full Screen

Full Screen

Exhaustive.Companion.lines

Using AI Code Generation

copy

Full Screen

1val lines = Exhaustive.lines(Paths.get("src/test/resources/lines.txt"))2val lines = Exhaustive.lines(Paths.get("src/test/resources/lines.txt"))3val lines = Exhaustive.lines(Paths.get("src/test/resources/lines.txt"))4val lines = Exhaustive.lines(Paths.get("src/test/resources/lines.txt"))5val lines = Exhaustive.lines(Paths.get("src/test/resources/lines.txt"))6val lines = Exhaustive.lines(Paths.get("src/test/resources/lines.txt"))7val lines = Exhaustive.lines(Paths.get("src/test/resources/lines.txt"))8val lines = Exhaustive.lines(Paths.get("src/test/resources/lines.txt"))9val lines = Exhaustive.lines(Paths.get("src/test/resources/lines.txt"))10val lines = Exhaustive.lines(Paths.get("src/test/resources/lines.txt"))11val lines = Exhaustive.lines(Paths.get("src/test/resources/lines.txt"))12val lines = Exhaustive.lines(Paths.get("src/test/resources/lines.txt"))13val lines = Exhaustive.lines(Paths.get("src/test/resources/lines.txt"))

Full Screen

Full Screen

Exhaustive.Companion.lines

Using AI Code Generation

copy

Full Screen

1val lines = Exhaustive . lines ( File ( "src/test/resources/test.txt" ))2val lines = Exhaustive . lines ( File ( "src/test/resources/test.txt" ), Charsets . UTF_8 )3val lines = Exhaustive . lines ( File ( "src/test/resources/test.txt" ), Charsets . UTF_8 , "4val lines = Exhaustive . lines ( File ( "src/test/resources/test.txt" ), "5val lines = Exhaustive . lines ( File ( "src/test/resources/test.txt" ), Charsets . UTF_8 , "6val lines = Exhaustive . lines ( File ( "src/test/resources/test.txt" ), "7val lines = Exhaustive . lines ( File ( "src/test/resources/test.txt" ), Charsets . UTF_8 , "8val lines = Exhaustive . lines ( File ( "src/test/resources/test.txt" ), "9val lines = Exhaustive . lines ( File ( "src/test/resources/test.txt" ), Charsets . UTF_8 , "10val lines = Exhaustive . lines ( File ( "src/test/resources/test.txt" ), "

Full Screen

Full Screen

Exhaustive.Companion.lines

Using AI Code Generation

copy

Full Screen

1val lines = Exhaustive.lines(Paths.get("C:/Users/.../file.txt"))2val lines = Exhaustive.lines(Paths.get("C:/Users/.../file.txt"), Charset.forName("UTF-8"))3val lines = Exhaustive.lines(Paths.get("C:/Users/.../file.txt"), Charsets.UTF_8)4val lines = Exhaustive.lines(Paths.get("C:/Users/.../file.txt"), "UTF-8")5val lines = Exhaustive.lines(Paths.get("C:/Users/.../file.txt"), "UTF-8", 4096)6val lines = Exhaustive.lines(Paths.get("C:/Users/.../file.txt"), "UTF-8", 4096, 10)7val lines = Exhaustive.lines(Paths.get("C:/Users/.../file.txt"), "UTF-8", 4096, 10, 100)8val lines = Exhaustive.lines(Paths.get("C:/Users/.../file.txt"), "UTF-8", 4096, 10, 100, 1000)9val lines = Exhaustive.lines(Paths.get("C:/Users/.../file.txt"), "UTF-8", 4096, 10, 100, 1000, 10000)10val lines = Exhaustive.lines(Paths.get("C:/Users/.../file.txt"), "UTF-8", 4096, 10, 100, 1000, 10000, 100000)11val lines = Exhaustive.lines(Paths.get("C:/Users/.../file.txt"), "UTF-8", 4096, 10, 100, 1000, 10000, 100000, 1000000)12val lines = Exhaustive.lines(Paths.get("C:/Users/.../file.txt"), "UTF-8", 4096, 10, 100, 1000, 10000, 100000, 1000000

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Kotest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Most used method in file

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful