-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #46 from Kaaveh/ci/cd_pipeline
Add CI/CD pipeline
- Loading branch information
Showing
4 changed files
with
61 additions
and
47 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
name: CI | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
tags: | ||
- v* | ||
pull_request: | ||
|
||
|
||
jobs: | ||
build: | ||
name: Build | ||
runs-on: ubuntu-latest | ||
steps: | ||
- run: echo "The job was automatically triggered by a ${{ github.event_name }} event." | ||
- run: echo "This job is running on a ${{ runner.os }} server hosted by GitHub!" | ||
- uses: actions/checkout@v3 | ||
- run: echo "The ${{ github.repository }} repository has been cloned." | ||
- run: echo "Setting up JDK" | ||
|
||
- name: set up JDK 11 | ||
uses: actions/setup-java@v3 | ||
with: | ||
distribution: 'zulu' | ||
java-version: 17 | ||
cache: gradle | ||
|
||
- run: echo "The workflow is now ready to test your code." | ||
- name: Grant execute permission for gradlew | ||
run: chmod +x gradlew | ||
|
||
- run: echo "Run unit tests" | ||
- name: Test | ||
run: ./gradlew test | ||
|
||
- run: echo "Assembling main outputs" | ||
- name: Assemble | ||
run: ./gradlew assemble | ||
- run: echo "Build status report=${{ job.status }}." | ||
|
||
- run: echo "Uploading build artifacts" | ||
- name: Upload a Build Artifact (APK) | ||
uses: actions/[email protected] | ||
with: | ||
name: app | ||
path: app/build/outputs/apk/debug/app-debug.apk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 12 additions & 16 deletions
28
domain/market/src/test/java/ir/kaaveh/domain/use_case/GetFavoriteMarketListUseCaseTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,34 @@ | ||
package ir.kaaveh.domain.use_case | ||
|
||
import io.mockk.every | ||
import io.mockk.mockk | ||
import io.mockk.verify | ||
import ir.kaaveh.domain.repository.MarketRepository | ||
import ir.kaaveh.domain.test.favoriteMarket | ||
import ir.kaaveh.domain.test.notFavoriteMarket | ||
import kotlinx.coroutines.ExperimentalCoroutinesApi | ||
import kotlinx.coroutines.flow.first | ||
import kotlinx.coroutines.flow.flow | ||
import kotlinx.coroutines.flow.flowOf | ||
import kotlinx.coroutines.test.runTest | ||
import org.junit.Assert.* | ||
import org.junit.Before | ||
import org.junit.Test | ||
import org.mockito.kotlin.doReturn | ||
import org.mockito.kotlin.mock | ||
|
||
@OptIn(ExperimentalCoroutinesApi::class) | ||
class GetFavoriteMarketListUseCaseTest { | ||
|
||
private lateinit var mockRepository: MarketRepository | ||
private val marketRepository: MarketRepository = mockk(relaxed = true) | ||
private lateinit var getFavoriteMarketListUseCase: GetFavoriteMarketListUseCase | ||
|
||
@Before | ||
fun provideRepository(){ | ||
mockRepository = mock { | ||
on { getMarketList() } doReturn flow { | ||
emit(listOf(favoriteMarket, notFavoriteMarket)) | ||
} | ||
} | ||
getFavoriteMarketListUseCase = GetFavoriteMarketListUseCase(repository = mockRepository) | ||
fun provideRepository() { | ||
getFavoriteMarketListUseCase = GetFavoriteMarketListUseCase(repository = marketRepository) | ||
} | ||
|
||
@Test | ||
fun checkGetOnlyFavoriteNews() = runTest { | ||
val news = getFavoriteMarketListUseCase().first() | ||
assertTrue(news.size == 1) | ||
every { marketRepository.getFavoriteMarketList() } returns flowOf(emptyList()) | ||
getFavoriteMarketListUseCase.invoke() | ||
verify(exactly = 1) { | ||
marketRepository.getFavoriteMarketList() | ||
} | ||
} | ||
|
||
} |