Skip to content

Commit

Permalink
Fix code format
Browse files Browse the repository at this point in the history
  • Loading branch information
agile-jordi committed Jun 2, 2023
1 parent 611d0be commit 7a6b2a5
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 12 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@ While developing:
- `./gradlew koverHtmlReport` to generate and open the test coverage report

To test your code:

- `docker-compose up`
- `./gradlew test`
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@ package com.agilogy.timetracking.toggl
import com.agilogy.timetracking.domain.ProjectName
import com.github.doyaaaaaken.kotlincsv.dsl.csvReader
import java.io.InputStream
import java.time.*
import java.time.Duration
import java.time.Instant
import java.time.LocalDate
import java.time.LocalDateTime
import java.time.LocalTime
import java.time.ZoneId
import java.time.temporal.ChronoUnit

fun readTogglCsv(inputStream: InputStream, zoneId: ZoneId): List<Triple<ProjectName, ClosedRange<Instant>, ZoneId>> =
Expand All @@ -16,6 +21,6 @@ fun readTogglCsv(inputStream: InputStream, zoneId: ZoneId): List<Triple<ProjectN
val startInstant = LocalDateTime.of(startDate, startTime).atZone(zoneId).toInstant()

val duration = Duration.of(parsedDuration.toSecondOfDay().toLong(), ChronoUnit.SECONDS)!!
val range = startInstant .. startInstant.plus(duration)
val range = startInstant..startInstant.plus(duration)
Triple(projectName, range, zoneId)
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,48 @@ package com.agilogy.timetracking.toggl

import com.agilogy.timetracking.domain.ProjectName
import io.kotest.core.spec.style.FunSpec
import org.junit.jupiter.api.Assertions.assertEquals
import java.time.Instant
import java.time.ZoneId
import org.junit.jupiter.api.Assertions.assertEquals

class TogglTest : FunSpec() {
init {
test("TODO") {
this::class.java.getResourceAsStream("/togglTimeEntries.csv").use { inputStream ->
val zoneId = ZoneId.of("Europe/Madrid")
val result: List<Triple<ProjectName, ClosedRange<Instant>, ZoneId>> = readTogglCsv(inputStream!!, zoneId)
val result: List<Triple<ProjectName, ClosedRange<Instant>, ZoneId>> = readTogglCsv(
inputStream!!,
zoneId,
)
val expected: List<Triple<ProjectName, ClosedRange<Instant>, ZoneId>> = listOf(
Triple(ProjectName("ProjectA"),Instant.parse("2023-05-12T06:30:00Z") .. Instant.parse("2023-05-12T14:30:00Z"), zoneId),
Triple(ProjectName("ProjectB"),Instant.parse("2023-05-15T06:30:00Z") .. Instant.parse("2023-05-15T14:30:00Z"), zoneId),
Triple(ProjectName("ProjectA"),Instant.parse("2023-05-15T14:30:00Z") .. Instant.parse("2023-05-15T16:30:00Z"), zoneId),
Triple(ProjectName("ProjectB"),Instant.parse("2023-05-16T06:30:00Z") .. Instant.parse("2023-05-16T14:30:00Z"), zoneId),
Triple(ProjectName("ProjectB"),Instant.parse("2023-05-17T06:30:00Z") .. Instant.parse("2023-05-17T14:30:00Z"), zoneId),
Triple(
ProjectName("ProjectA"),
Instant.parse("2023-05-12T06:30:00Z")..Instant.parse("2023-05-12T14:30:00Z"),
zoneId,
),
Triple(
ProjectName("ProjectB"),
Instant.parse("2023-05-15T06:30:00Z")..Instant.parse("2023-05-15T14:30:00Z"),
zoneId,
),
Triple(
ProjectName("ProjectA"),
Instant.parse("2023-05-15T14:30:00Z")..Instant.parse("2023-05-15T16:30:00Z"),
zoneId,
),
Triple(
ProjectName("ProjectB"),
Instant.parse("2023-05-16T06:30:00Z")..Instant.parse("2023-05-16T14:30:00Z"),
zoneId,
),
Triple(
ProjectName("ProjectB"),
Instant.parse("2023-05-17T06:30:00Z")..Instant.parse("2023-05-17T14:30:00Z"),
zoneId,
),
)
assertEquals(expected, result)
}
}
}


}
}

0 comments on commit 7a6b2a5

Please sign in to comment.