Skip to content

Commit

Permalink
Fix race conditions in unit test
Browse files Browse the repository at this point in the history
Added delays after clearing database table to prevent race conditions
  • Loading branch information
A-Flying-Poro committed Jan 15, 2023
1 parent 65ec310 commit a4dada3
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<groupId>com.nevakanezah</groupId>
<artifactId>HorseEnhancer</artifactId>
<packaging>jar</packaging>
<version>2.1.1</version>
<version>2.1.2</version>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: 'HorseEnhancer'
version: '2.1.1'
version: '2.1.2'
api-version: '1.18'
main: 'com.nevakanezah.horseenhancer.HorseEnhancerMain'
authors:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import com.nevakanezah.horseenhancer.HorseEnhancerMain
import com.nevakanezah.horseenhancer.database.SQLiteDatabase
import com.nevakanezah.horseenhancer.test.mccoroutine.impl.TestMCCoroutineImpl
import com.nevakanezah.horseenhancer.util.HorseUtil
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.collect
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.runBlocking
Expand Down Expand Up @@ -71,6 +72,8 @@ internal object HorseInspectionTest {
horse.remove()
database.getHorsesEntity().map { it.second }.collect { it.remove() }
database.removeInvalidHorses()
// Added due to possible race condition from clearing Horse table in database
delay(10)
}

@Test
Expand Down

0 comments on commit a4dada3

Please sign in to comment.