Skip to content

Commit

Permalink
fix CI
Browse files Browse the repository at this point in the history
  • Loading branch information
stslex committed Aug 7, 2023
1 parent bafc37a commit 3b92471
Show file tree
Hide file tree
Showing 16 changed files with 160 additions and 108 deletions.
12 changes: 11 additions & 1 deletion .github/workflows/android_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ on:
branches: [ master ]
workflow_dispatch:

permissions:
checks: write
pull-requests: write

jobs:
build:

Expand Down Expand Up @@ -37,4 +41,10 @@ jobs:
run: ./gradlew build

- name: Junit tests with Gradle
run: ./gradlew testDebugUnitTest
run: ./gradlew testDebugUnitTest

- name: Publish Test Results
uses: EnricoMi/publish-unit-test-result-action@v2
if: always()
with:
files: "**/build/test-results/**/*.xml"
16 changes: 8 additions & 8 deletions app/src/test/java/com/stslex/aproselection/DiKoinModuleTest.kt
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
package com.stslex.aproselection

import android.content.Context
import androidx.navigation.NavHostController
import com.stslex.aproselection.core.datastore.coreDataStoreModule
import com.stslex.aproselection.core.navigation.di.moduleCoreNavigation
import com.stslex.aproselection.core.network.di.ModuleCoreNetwork.moduleCoreNetwork
import com.stslex.aproselection.core.navigation.destination.NavigationScreen
import com.stslex.aproselection.core.user.di.moduleCoreUser
import com.stslex.aproselection.di.appModule
import com.stslex.aproselection.di.initialAppModule
import com.stslex.aproselection.feature.auth.di.ModuleFeatureAuth.moduleFeatureAuth
import com.stslex.aproselection.feature.home.di.moduleFeatureHome
import org.junit.Test
import org.koin.android.ext.koin.androidContext
import org.koin.dsl.koinApplication
import org.koin.dsl.module
import org.koin.test.KoinTest
import org.koin.test.check.checkModules
import org.mockito.Mockito
Expand All @@ -19,19 +21,17 @@ class DiKoinModuleTest : KoinTest {

@Test
fun checkKoinModules() {
val navigator: (screen: com.stslex.aproselection.core.navigation.destination.NavigationScreen) -> Unit = {}
val navController = Mockito.mock(NavHostController::class.java)

koinApplication {

androidContext(Mockito.mock(Context::class.java))
modules(
module {
single {
navigator
}
},
moduleCoreNavigation(navController),
initialAppModule,
appModule,
moduleCoreNetwork,
moduleCoreUser,
coreDataStoreModule,
moduleFeatureAuth,
moduleFeatureHome,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.stslex.aproselection.core.datastore

import android.content.Context
import org.junit.Test
import org.koin.android.ext.koin.androidContext
import org.koin.dsl.koinApplication
import org.koin.test.KoinTest
import org.koin.test.check.checkModules
import org.mockito.Mockito

class CoreDataStoreModuleTest : KoinTest {

@Test
fun checkKoinModules() {

koinApplication {
androidContext(Mockito.mock(Context::class.java))
modules(coreDataStoreModule)
checkModules()
}
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.stslex.aproselection.core.navigation

import android.content.Context
import androidx.navigation.NavHostController
import com.stslex.aproselection.core.navigation.di.moduleCoreNavigation
import org.junit.Test
import org.koin.android.ext.koin.androidContext
import org.koin.dsl.koinApplication
import org.koin.test.KoinTest
import org.koin.test.check.checkModules
import org.mockito.Mockito

class CoreNavigationModuleTest : KoinTest {

@Test
fun checkKoinModules() {
val navController = Mockito.mock(NavHostController::class.java)

koinApplication {
androidContext(Mockito.mock(Context::class.java))
modules(moduleCoreNavigation(navController))
checkModules()
}
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ package com.stslex.aproselection.core.network.clients.user
import com.stslex.aproselection.core.network.client.NetworkClient
import com.stslex.aproselection.core.network.clients.user.model.UpdateUserInfoBody
import com.stslex.aproselection.core.network.clients.user.model.UserResponse
import com.stslex.aproselection.core.network.model.PagingRequest
import io.ktor.client.call.body
import io.ktor.client.request.get
import io.ktor.client.request.post
import io.ktor.client.request.setBody
import io.ktor.http.appendPathSegments
import io.ktor.util.AttributeKey
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext

Expand All @@ -22,12 +22,10 @@ class UserNetworkClientImpl(
): List<UserResponse> = withContext(Dispatchers.IO) {
networkClient.apiClient.get {
url.appendPathSegments("user", "list")
setBody(
PagingRequest(
pageSize = pageSize,
pageNumber = page
)
)
setAttributes {
put(AttributeKey("page_size"), pageSize)
put(AttributeKey("page_number"), page)
}
}.body()
}

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.stslex.aproselection.core.network

import android.content.Context
import com.stslex.aproselection.core.datastore.coreDataStoreModule
import com.stslex.aproselection.core.network.di.ModuleCoreNetwork.moduleCoreNetwork
import org.junit.Test
import org.koin.android.ext.koin.androidContext
Expand All @@ -15,7 +16,10 @@ class DiKoinModuleTest : KoinTest {
fun checkKoinModules() {
koinApplication {
androidContext(Mockito.mock(Context::class.java))
modules(moduleCoreNetwork)
modules(
moduleCoreNetwork,
coreDataStoreModule
)
checkModules()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ class BasePagingSource<T : Any>(
}

companion object {
const val INITIAL_PAGE_NUMBER = 1
const val INITIAL_PAGE_NUMBER = 0
}
}
2 changes: 2 additions & 0 deletions core/user/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@ android.namespace = "com.stslex.aproselection.core.user"
dependencies {
implementation(project(":core:core"))
implementation(project(":core:network"))
testImplementation(project(":core:core"))
androidTestImplementation(project(":core:core"))
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.stslex.aproselection.core.user

import android.content.Context
import com.stslex.aproselection.core.network.clients.user.UserNetworkClient
import com.stslex.aproselection.core.user.di.moduleCoreUser
import org.junit.Test
import org.koin.android.ext.koin.androidContext
import org.koin.core.KoinApplication
import org.koin.dsl.koinApplication
import org.koin.dsl.module
import org.koin.test.KoinTest
import org.koin.test.check.checkModules
import org.mockito.Mockito

class CoreUserModuleTest : KoinTest {

@Test
fun checkKoinModules() {
koinApplication {
androidContext(Mockito.mock(Context::class.java))
load<UserNetworkClient>()
modules(moduleCoreUser)
checkModules()
}
}

private inline fun <reified T> KoinApplication.load() {
koin.loadModules(
listOf(module { single<T> { Mockito.mock(T::class.java) } })
)
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
package com.stslex.aproselection.feature.auth

import android.content.Context
import com.stslex.aproselection.core.network.di.ModuleCoreNetwork.moduleCoreNetwork
import com.stslex.aproselection.core.datastore.AppDataStore
import com.stslex.aproselection.core.navigation.navigator.Navigator
import com.stslex.aproselection.core.network.clients.auth.AuthNetworkClient
import com.stslex.aproselection.feature.auth.di.ModuleFeatureAuth.moduleFeatureAuth
import org.junit.Test
import org.koin.android.ext.koin.androidContext
import org.koin.core.KoinApplication
import org.koin.dsl.koinApplication
import org.koin.dsl.module
import org.koin.test.KoinTest
import org.koin.test.check.checkModules
import org.mockito.Mockito
Expand All @@ -16,11 +20,17 @@ class ModuleFeatureAuthTest : KoinTest {
fun checkKoinModules() {
koinApplication {
androidContext(Mockito.mock(Context::class.java))
modules(
moduleFeatureAuth,
moduleCoreNetwork
)
load<Navigator>()
load<AuthNetworkClient>()
load<AppDataStore>()
modules(moduleFeatureAuth)
checkModules()
}
}

private inline fun <reified T> KoinApplication.load() {
koin.loadModules(
listOf(module { single<T> { Mockito.mock(T::class.java) } })
)
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.stslex.aproselection.feature.home

import android.content.Context
import com.stslex.aproselection.core.datastore.AppDataStore
import com.stslex.aproselection.core.user.data.repository.UserRepository
import com.stslex.aproselection.feature.home.di.moduleFeatureHome
import org.junit.Test
import org.koin.android.ext.koin.androidContext
import org.koin.core.KoinApplication
import org.koin.dsl.koinApplication
import org.koin.dsl.module
import org.koin.test.KoinTest
import org.koin.test.check.checkModules
import org.mockito.Mockito

class ModuleFeatureHomeTest : KoinTest {

@Test
fun checkKoinModules() {
koinApplication {
androidContext(Mockito.mock(Context::class.java))
load<UserRepository>()
load<AppDataStore>()
modules(moduleFeatureHome)
checkModules()
}
}

private inline fun <reified T> KoinApplication.load() {
koin.loadModules(
listOf(module { single<T> { Mockito.mock(T::class.java) } })
)
}
}

0 comments on commit 3b92471

Please sign in to comment.