Skip to content

Commit

Permalink
delete timber for the meantime
Browse files Browse the repository at this point in the history
  • Loading branch information
Souleymane Sidibe committed Aug 14, 2021
1 parent bdbcc88 commit ff93a60
Show file tree
Hide file tree
Showing 6 changed files with 84 additions and 7 deletions.
2 changes: 0 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,6 @@ dependencies {
implementation("androidx.compose.material:material-icons-extended:${compose_version}")
implementation("com.google.accompanist:accompanist-systemuicontroller:0.14.0")

implementation("com.jakewharton.timber:timber:5.0.1")

implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.4.0-alpha03")
// implementation("androidx.lifecycle:lifecycle-livedata-ktx:2.3.1")
implementation("androidx.activity:activity-compose:1.3.1")
Expand Down
1 change: 0 additions & 1 deletion data/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,4 @@ dependencies {
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.1"
implementation("io.insert-koin:koin-core:3.1.2")

implementation("com.jakewharton.timber:timber:5.0.1")
}
2 changes: 0 additions & 2 deletions device/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@ dependencies {
implementation 'androidx.appcompat:appcompat:1.3.1'
implementation 'com.google.android.material:material:1.4.0'

implementation("com.jakewharton.timber:timber:5.0.1")

def room_version = "2.3.0"
implementation("androidx.room:room-runtime:$room_version")
implementation("androidx.room:room-ktx:$room_version")
Expand Down
3 changes: 1 addition & 2 deletions domain/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,10 @@ dependencies {
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.1"
implementation("io.insert-koin:koin-core:3.1.2")

implementation("com.jakewharton.timber:timber:5.0.1")

testImplementation("junit:junit:4.13.2")
testImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.5.1")
testImplementation("org.hamcrest:hamcrest-all:1.3")
testImplementation("org.mockito:mockito-core:3.9.0")
testImplementation("io.mockk:mockk:1.10.0")
testImplementation("io.insert-koin:koin-test:3.1.2")
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package com.soulesidibe.domain

import com.soulesidibe.domain.entity.TodoEntity
import com.soulesidibe.domain.exception.NoTodoFoundException
import com.soulesidibe.domain.repository.TodoRepository
import junit.framework.TestCase.assertEquals
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.test.runBlockingTest
import org.junit.Test
import org.mockito.Mockito.`when`
import org.mockito.Mockito.mock

@ExperimentalCoroutinesApi
class GetTodoUseCaseTest {

@Test
fun `should get a todo`() = runBlockingTest {
val fakeId = "12345"
val repository = mock(TodoRepository::class.java)
`when`(repository.byId(fakeId)).thenReturn(TodoEntity("12345", "Test"))

val usecase = GetTodoUseCase(repository)

val response = usecase.execute(fakeId)
assertEquals(
Response.success(TodoEntity("12345", "Test")),
response
)
}

@Test
fun `should get an error when no todo id do no exist`() = runBlockingTest {
val fakeId = "12345"
val repository = mock(TodoRepository::class.java)
`when`(repository.byId(fakeId)).thenReturn(null)

val usecase = GetTodoUseCase(repository)

val response = usecase.execute(fakeId)
assertEquals(
Response.failure<NoTodoFoundException>(NoTodoFoundException),
response
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package com.soulesidibe.domain

import com.soulesidibe.domain.entity.TodoEntity
import com.soulesidibe.domain.exception.NoTodoFoundException
import com.soulesidibe.domain.repository.TodoRepository
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.test.runBlockingTest
import org.junit.Assert.*
import org.junit.Test
import org.mockito.Mockito.`when`
import org.mockito.Mockito.mock

@OptIn(ExperimentalCoroutinesApi::class)
class RemoveTodoUseCaseTest {


@Test
fun `should remove the todo if exsist`() = runBlockingTest {
val repository = mock(TodoRepository::class.java)
`when`(repository.byId("12345")).thenReturn(TodoEntity("12345", "test"))
`when`(repository.remove(TodoEntity("12345", "test"))).thenReturn(true)


val usecase = RemoveTodoUseCase(repository)
val response = usecase.execute("12345")
assertEquals(Response.success(true), response)
}

@Test
fun `should not remove the todo if not exsist`() = runBlockingTest {
val repository = mock(TodoRepository::class.java)
`when`(repository.byId("12345")).thenReturn(null)

val usecase = RemoveTodoUseCase(repository)
val response = usecase.execute("12345")
assertEquals(Response.Error<NoTodoFoundException>(NoTodoFoundException), response)
}
}

0 comments on commit ff93a60

Please sign in to comment.