Skip to content

Commit

Permalink
fix: fix test initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
yangchanhk98 committed Dec 10, 2023
1 parent 23cb64b commit 7f45d81
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,12 @@ internal class EmojiDaoTest {
for (emoji in testDto.emojiList) {
testDB.collection(EMOJI_COLLECTION_NAME.string).document(emoji.id).set(emoji)
}
var docs = testDB.collection(EMOJI_COLLECTION_NAME.string).get().get().documents
var a = 1
while (docs.size != testDto.emojiList.size && a <= 5) {
docs = testDB.collection(EMOJI_COLLECTION_NAME.string).get().get().documents
a++
}
}
}

Expand Down Expand Up @@ -236,6 +242,13 @@ internal class EmojiDaoTest {
testDB.collection(EMOJI_COLLECTION_NAME.string)
.document(emojiId)
.set(emojiList[3])
result = emojiDao.existsEmoji(emojiId)
var b = 1
while (!result && b <= 5) {
result = emojiDao.existsEmoji(emojiId)
b++
}
assertEquals(result, true)
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ internal class PostDaoTest {
for (post in testDto.postList) {
testDB.collection(POST_COLLECTION_NAME.string).document(post.id).set(post)
}
var docs = testDB.collection(POST_COLLECTION_NAME.string).get().get().documents
var a = 1
while (docs.size != testDto.postList.size && a <= 5) {
docs = testDB.collection(POST_COLLECTION_NAME.string).get().get().documents
a++
}
}
}

Expand Down Expand Up @@ -124,8 +130,12 @@ internal class PostDaoTest {
val index = 1
val count = testDto.postSize
val postListForUser = mutableListOf<PostDto>()
postListForUser.add(postList[1])
postListForUser.add(postList[0])
for (post in testDto.postList) {
if (post.created_by == username) {
postListForUser.add(post)
}
}
postListForUser.sortByDescending { it.created_at }
Mockito.`when`(db.collection(POST_COLLECTION_NAME.string))
.thenReturn(testDB.collection(POST_COLLECTION_NAME.string))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@ internal class ReactionDaoTest {
for (reaction in testDto.reactionList) {
testDB.collection(REACTION_COLLECTION_NAME.string).document(reaction.id).set(reaction)
}
var docs = testDB.collection(REACTION_COLLECTION_NAME.string).get().get().documents
var a = 1
while (docs.size != testDto.reactionList.size && a <= 5) {
docs = testDB.collection(REACTION_COLLECTION_NAME.string).get().get().documents
a++
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@ internal class UserDaoTest {
for (user in testDto.userList) {
testDB.collection(USER_COLLECTION_NAME.string).document(user.username).set(user)
}
var docs = testDB.collection(USER_COLLECTION_NAME.string).get().get().documents
var a = 1
while (docs.size != testDto.userList.size && a <= 5) {
docs = testDB.collection(USER_COLLECTION_NAME.string).get().get().documents
a++
}
}
}

Expand Down

0 comments on commit 7f45d81

Please sign in to comment.