This is a problem that has been really puzzling. For some reason, equals method fails here:
val newItem = testPlaylistItem.copy(id = returnedItem.id, index = 0, updatedAt = newPlaylistFromDb.updatedAt)
assertEquals(newPlaylistFromDb, newItem)
As you can see, I'm just overwriting some properties that I know that change and I can't control (id isn't known since it's generated by the persistence and index and updatedAt are internally generated). Basically what I'm doing is ignoring them for the test at hand. This test is successful locally all the time but randomly fails when run by the compilation inside a Docker container (in CI pipeline). As displayed in the error, it shows a small difference: 2022-06-20T15:50:45.187Z vs 2022-06-20T15:50:45.186Z.
What I've tried so far is decompiling the generated bytecode into Java and I can't see the reason why this could happen. Apparently the copy method would pass the instant parameter by reference to instantiate a new object.
The stack and versions I'm using are:
- Docker image: openjdk:11.0.3-jre-slim
- Gradle 6.9.2
- Kotlin 1.4.10