generated from JetBrains/compose-multiplatform-template
-
-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Lock clock when testing date time formatters
This is done to fix the failing date formatters test. The reason it fails is, since one of the date format we have doesn't have year attached to it "MM-dd HH:mm:ss", it picks it from the current system time. The expected value I provided was for year 2023, but since the year is now 2024, the tests has started to fail. So locking the clock (which I should've done from the start) to a specific date time, so that the tests are reproducible.
- Loading branch information
1 parent
df7d081
commit 3083fe2
Showing
5 changed files
with
54 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
core/network/src/commonTest/kotlin/dev/sasikanth/rss/reader/core/network/parser/TestClock.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* Copyright 2024 Sasikanth Miriyampalli | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package dev.sasikanth.rss.reader.core.network.parser | ||
|
||
import kotlinx.datetime.Clock | ||
import kotlinx.datetime.Instant | ||
import kotlinx.datetime.LocalDateTime | ||
import kotlinx.datetime.Month | ||
import kotlinx.datetime.TimeZone | ||
import kotlinx.datetime.toInstant | ||
|
||
object TestClock : Clock { | ||
|
||
override fun now(): Instant { | ||
return LocalDateTime( | ||
year = 2023, | ||
month = Month.JANUARY, | ||
dayOfMonth = 1, | ||
hour = 8, | ||
minute = 0, | ||
) | ||
.toInstant(TimeZone.UTC) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters