Skip to content

Commit c7b49f8

Browse files
committed
time partials failure in test because of microseconds rounding
1 parent d305d10 commit c7b49f8

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

backend/mr-db-sql/src/test/groovy/io/featurehub/db/services/AuthenticationSpec.groovy

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ import org.apache.commons.lang3.RandomStringUtils
1717
import spock.lang.Shared
1818

1919
import java.time.Instant
20+
import java.time.temporal.ChronoField
21+
import java.time.temporal.TemporalField
2022

2123
class AuthenticationSpec extends BaseSpec {
2224
@Shared AuthenticationSqlApi auth
@@ -258,7 +260,7 @@ class AuthenticationSpec extends BaseSpec {
258260
then:
259261
session == originalSession
260262
foundSession.token == originalSession.token
261-
foundSession.lastSeen == originalSession.lastSeen
263+
foundSession.lastSeen.with(ChronoField.MICRO_OF_SECOND, 0) == originalSession.lastSeen.with(ChronoField.MICRO_OF_SECOND, 0)
262264
foundSession.person.id.id == p2.id.id
263265
foundSession.person.email == p2.email
264266
invalidSession == null

backend/mr-db-sql/src/test/groovy/io/featurehub/db/services/ConvertUtilsSpec.groovy

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import io.featurehub.mr.model.SortOrder
1414
import java.time.Instant
1515
import java.time.LocalDateTime
1616
import java.time.ZoneOffset
17+
import java.time.temporal.ChronoField
1718

1819
class ConvertUtilsSpec extends Base2Spec {
1920
PersonSqlApi personSqlApi
@@ -54,7 +55,7 @@ class ConvertUtilsSpec extends Base2Spec {
5455
def peopleClean = personSqlApi.search(email, SortOrder.ASC, 0, 0, Set.of(PersonType.PERSON), null, Opts.empty())
5556
then:
5657
people.people.size() == 1
57-
people.people[0].whenLastAuthenticated == whenLastAuthenticated.atOffset(ZoneOffset.UTC)
58+
people.people[0].whenLastAuthenticated.with(ChronoField.MICRO_OF_SECOND, 0) == whenLastAuthenticated.atOffset(ZoneOffset.UTC).with(ChronoField.MICRO_OF_SECOND, 0)
5859
people.people[0].whenLastSeen == null
5960
peopleClean.people.size() == 1
6061
peopleClean.people[0].whenLastAuthenticated == null
@@ -80,8 +81,8 @@ class ConvertUtilsSpec extends Base2Spec {
8081
def peopleClean = personSqlApi.search(email, SortOrder.ASC, 0, 0, Set.of(PersonType.PERSON), null, Opts.empty())
8182
then:
8283
people.people.size() == 1
83-
people.people[0].whenLastAuthenticated == whenLastAuthenticated.atOffset(ZoneOffset.UTC)
84-
people.people[0].whenLastSeen == whenLastSeen.atOffset(ZoneOffset.UTC)
84+
people.people[0].whenLastAuthenticated.with(ChronoField.MICRO_OF_SECOND, 0) == whenLastAuthenticated.atOffset(ZoneOffset.UTC).with(ChronoField.MICRO_OF_SECOND, 0)
85+
people.people[0].whenLastSeen.with(ChronoField.MICRO_OF_SECOND, 0) == whenLastSeen.atOffset(ZoneOffset.UTC).with(ChronoField.MICRO_OF_SECOND, 0)
8586
peopleClean.people.size() == 1
8687
peopleClean.people[0].whenLastAuthenticated == null
8788
peopleClean.people[0].whenLastSeen == null

backend/mr-db-sql/src/test/groovy/io/featurehub/db/services/WebhookSpec.groovy

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import io.featurehub.webhook.events.WebhookEnvironmentResult
99
import io.featurehub.webhook.events.WebhookMethod
1010

1111
import java.time.OffsetDateTime
12+
import java.time.temporal.ChronoField
1213

1314
class WebhookSpec extends Base3Spec {
1415
WebhookSqlApi webhookApi
@@ -52,7 +53,7 @@ class WebhookSpec extends Base3Spec {
5253
def more = webhookApi.getWebhookDetails(env1.id, result.results[0].id, Opts.opts(FillOpts.Details))
5354
then:
5455
result.max == 1
55-
result.results[0].whenSent == data.whenSent
56+
result.results[0].whenSent.with(ChronoField.MICRO_OF_SECOND, 0) == data.whenSent.with(ChronoField.MICRO_OF_SECOND, 0)
5657
result.results[0].method == 'POST'
5758
result.results[0].status == 200
5859
result.results[0].id != null

0 commit comments

Comments
 (0)