Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
AloqaIM-Android
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
AloqaIM-Android
Commits
24860c1a
Commit
24860c1a
authored
Apr 24, 2018
by
Marius Volkhart
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Restore unit tests
parent
2d35ff14
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
70 additions
and
55 deletions
+70
-55
config.yml
.circleci/config.yml
+1
-1
MemoryMessagesRepositoryTest.kt
.../java/chat/rocket/android/MemoryMessagesRepositoryTest.kt
+69
-54
No files found.
.circleci/config.yml
View file @
24860c1a
...
@@ -57,7 +57,7 @@ jobs:
...
@@ -57,7 +57,7 @@ jobs:
command
:
./gradlew lint
command
:
./gradlew lint
-
run
:
-
run
:
name
:
Run Unit test
name
:
Run Unit test
command
:
echo ./gradlew test
# TODO: Fix unit test errors soon...
command
:
./gradlew test
-
store_artifacts
:
-
store_artifacts
:
path
:
app/build/reports/
path
:
app/build/reports/
destination
:
reports
destination
:
reports
...
...
app/src/test/java/chat/rocket/android/MemoryMessagesRepositoryTest.kt
View file @
24860c1a
...
@@ -3,6 +3,7 @@ package chat.rocket.android
...
@@ -3,6 +3,7 @@ package chat.rocket.android
import
chat.rocket.android.server.infraestructure.MemoryMessagesRepository
import
chat.rocket.android.server.infraestructure.MemoryMessagesRepository
import
chat.rocket.core.model.Message
import
chat.rocket.core.model.Message
import
chat.rocket.core.model.MessageType
import
chat.rocket.core.model.MessageType
import
kotlinx.coroutines.experimental.runBlocking
import
org.hamcrest.CoreMatchers.notNullValue
import
org.hamcrest.CoreMatchers.notNullValue
import
org.hamcrest.MatcherAssert.assertThat
import
org.hamcrest.MatcherAssert.assertThat
import
org.junit.Before
import
org.junit.Before
...
@@ -30,7 +31,9 @@ class MemoryMessagesRepositoryTest {
...
@@ -30,7 +31,9 @@ class MemoryMessagesRepositoryTest {
senderAlias
=
null
,
senderAlias
=
null
,
type
=
MessageType
.
MessageRemoved
(),
type
=
MessageType
.
MessageRemoved
(),
updatedAt
=
1511443964815
,
updatedAt
=
1511443964815
,
urls
=
null
urls
=
null
,
pinned
=
false
,
reactions
=
null
)
)
val
msg2
=
Message
(
val
msg2
=
Message
(
...
@@ -50,16 +53,21 @@ class MemoryMessagesRepositoryTest {
...
@@ -50,16 +53,21 @@ class MemoryMessagesRepositoryTest {
senderAlias
=
null
,
senderAlias
=
null
,
type
=
MessageType
.
MessageRemoved
(),
type
=
MessageType
.
MessageRemoved
(),
updatedAt
=
1511443964818
,
updatedAt
=
1511443964818
,
urls
=
null
urls
=
null
,
pinned
=
false
,
reactions
=
null
)
)
@Before
@Before
fun
setup
()
{
fun
setup
()
{
runBlocking
{
repository
.
clear
()
repository
.
clear
()
}
}
}
@Test
@Test
fun
`
save
()
should
save
a
single
message
`
()
{
fun
`
save
()
should
save
a
single
message
`
()
{
runBlocking
{
assertThat
(
repository
.
getAll
().
size
,
isEqualTo
(
0
))
assertThat
(
repository
.
getAll
().
size
,
isEqualTo
(
0
))
repository
.
save
(
msg
)
repository
.
save
(
msg
)
val
allMessages
=
repository
.
getAll
()
val
allMessages
=
repository
.
getAll
()
...
@@ -70,9 +78,11 @@ class MemoryMessagesRepositoryTest {
...
@@ -70,9 +78,11 @@ class MemoryMessagesRepositoryTest {
assertThat
(
roomId
,
isEqualTo
(
"GENERAL"
))
assertThat
(
roomId
,
isEqualTo
(
"GENERAL"
))
}
}
}
}
}
@Test
@Test
fun
`
saveAll
()
should
all
saved
messages
`
()
{
fun
`
saveAll
()
should
all
saved
messages
`
()
{
runBlocking
{
assertThat
(
repository
.
getAll
().
size
,
isEqualTo
(
0
))
assertThat
(
repository
.
getAll
().
size
,
isEqualTo
(
0
))
repository
.
saveAll
(
listOf
(
msg
,
msg2
))
repository
.
saveAll
(
listOf
(
msg
,
msg2
))
val
allMessages
=
repository
.
getAll
()
val
allMessages
=
repository
.
getAll
()
...
@@ -89,9 +99,11 @@ class MemoryMessagesRepositoryTest {
...
@@ -89,9 +99,11 @@ class MemoryMessagesRepositoryTest {
assertThat
(
roomId
,
isEqualTo
(
"sandbox"
))
assertThat
(
roomId
,
isEqualTo
(
"sandbox"
))
}
}
}
}
}
@Test
@Test
fun
`
getById
()
should
return
a
single
message
`
()
{
fun
`
getById
()
should
return
a
single
message
`
()
{
runBlocking
{
repository
.
saveAll
(
listOf
(
msg
,
msg2
))
repository
.
saveAll
(
listOf
(
msg
,
msg2
))
var
singleMsg
=
repository
.
getById
(
"messageId"
)
var
singleMsg
=
repository
.
getById
(
"messageId"
)
assertThat
(
singleMsg
,
notNullValue
())
assertThat
(
singleMsg
,
notNullValue
())
...
@@ -109,9 +121,11 @@ class MemoryMessagesRepositoryTest {
...
@@ -109,9 +121,11 @@ class MemoryMessagesRepositoryTest {
assertThat
(
roomId
,
isEqualTo
(
"sandbox"
))
assertThat
(
roomId
,
isEqualTo
(
"sandbox"
))
}
}
}
}
}
@Test
@Test
fun
`
getByRoomId
()
should
return
all
messages
for
room
id
or
an
empty
list
`
()
{
fun
`
getByRoomId
()
should
return
all
messages
for
room
id
or
an
empty
list
`
()
{
runBlocking
{
repository
.
saveAll
(
listOf
(
msg
,
msg2
))
repository
.
saveAll
(
listOf
(
msg
,
msg2
))
var
roomMessages
=
repository
.
getByRoomId
(
"faAad32fkasods2"
)
var
roomMessages
=
repository
.
getByRoomId
(
"faAad32fkasods2"
)
assertThat
(
roomMessages
.
isEmpty
(),
isEqualTo
(
true
))
assertThat
(
roomMessages
.
isEmpty
(),
isEqualTo
(
true
))
...
@@ -132,4 +146,5 @@ class MemoryMessagesRepositoryTest {
...
@@ -132,4 +146,5 @@ class MemoryMessagesRepositoryTest {
assertThat
(
roomId
,
isEqualTo
(
"GENERAL"
))
assertThat
(
roomId
,
isEqualTo
(
"GENERAL"
))
}
}
}
}
}
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment