Skip to content

Commit

Permalink
fix test failures
Browse files Browse the repository at this point in the history
  • Loading branch information
7hong13 committed Aug 23, 2023
1 parent fd794f6 commit 627fd00
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 48 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,9 @@ jobs:
ram-size: 4096M
emulator-boot-timeout: 12000
disable-animations: true
script: ./gradlew yorkie:connectedCheck --no-build-cache --no-daemon --stacktrace
script: |
./gradlew yorkie:connectedCheck -Pandroid.testInstrumentationRunnerArguments.notAnnotation=androidx.test.filters.LargeTest --no-build-cache --no-daemon --stacktrace
./gradlew yorkie:connectedCheck -Pandroid.testInstrumentationRunnerArguments.annotation=androidx.test.filters.LargeTest --no-build-cache --no-daemon --stacktrace
- if: ${{ matrix.api-level == 30 }}
run: ./gradlew yorkie:jacocoDebugTestReport
- if: ${{ matrix.api-level == 30 }}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package dev.yorkie.document.json

import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.LargeTest
import dev.yorkie.core.Client
import dev.yorkie.core.Presence
import dev.yorkie.core.withTwoClientsAndDocuments
Expand All @@ -12,6 +13,7 @@ import org.junit.Test
import org.junit.runner.RunWith
import kotlin.test.assertEquals

@LargeTest
@RunWith(AndroidJUnit4::class)
class JsonTreeTest {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public class JsonObject internal constructor(
val ticket = context.issueTimeTicket()
val tree = CrdtTree(JsonTree.buildRoot(initialRoot, context), ticket)
setAndRegister(key, tree)
return JsonTree(context, tree)
return tree.toJsonElement(context)
}

private fun setAndRegister(key: String, element: CrdtElement) {
Expand Down
97 changes: 51 additions & 46 deletions yorkie/src/test/kotlin/dev/yorkie/document/json/JsonTreeTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -532,57 +532,62 @@ class JsonTreeTest {
}
},
)
}.await()
assertEquals("<doc><tc><p><tn>ab</tn></p></tc></doc>", document.getRoot().tree().toXml())
assertEquals(
"<doc><tc><p><tn>ab</tn></p></tc></doc>",
document.getRoot().tree().toXml(),
)

document.getRoot().tree().editByPath(
listOf(0, 0, 0, 1),
listOf(0, 0, 0, 1),
text { "X" },
text { "X" },
)
assertEquals("<doc><tc><p><tn>aXXb</tn></p></tc></doc>", document.getRoot().tree().toXml())
root.tree().editByPath(
listOf(0, 0, 0, 1),
listOf(0, 0, 0, 1),
text { "X" },
text { "X" },
)
assertEquals(
"<doc><tc><p><tn>aXXb</tn></p></tc></doc>",
document.getRoot().tree().toXml(),
)

document.getRoot().tree().editByPath(
listOf(0, 1),
listOf(0, 1),
element("p") {
element("tn") {
text { "te" }
text { "st" }
}
},
element("p") {
root.tree().editByPath(
listOf(0, 1),
listOf(0, 1),
element("p") {
element("tn") {
text { "te" }
text { "st" }
}
},
element("p") {
element("tn") {
text { "te" }
text { "xt" }
}
},
)
assertEquals(
"<doc><tc><p><tn>aXXb</tn></p><p><tn>test</tn></p><p><tn>text</tn></p></tc></doc>",
document.getRoot().tree().toXml(),
)

root.tree().editByPath(
listOf(0, 3),
listOf(0, 3),
element("p") {
element("tn") {
text { "te" }
text { "st" }
}
},
element("tn") {
text { "te" }
text { "xt" }
}
},
)
assertEquals(
"<doc><tc><p><tn>aXXb</tn></p><p><tn>test</tn></p><p><tn>text</tn></p></tc></doc>",
document.getRoot().tree().toXml(),
)

// TODO(7hong13): the test should be passed when text contents values are "test" and "text"
document.getRoot().tree().editByPath(
listOf(0, 3),
listOf(0, 3),
element("p") {
element("tn") {
text { "12" }
text { "34" }
}
},
element("tn") {
text { "56" }
text { "78" }
},
)
assertEquals(
"<doc><tc><p><tn>aXXb</tn></p><p><tn>test</tn></p><p><tn>text</tn></p><p><tn>1234</tn></p><tn>5678</tn></tc></doc>",
document.getRoot().tree().toXml(),
)
},
)
assertEquals(
"<doc><tc><p><tn>aXXb</tn></p><p><tn>test</tn></p><p><tn>text</tn></p><p><tn>test</tn></p><tn>text</tn></tc></doc>",
document.getRoot().tree().toXml(),
)
}.await()
}

@Test
Expand Down

0 comments on commit 627fd00

Please sign in to comment.