Skip to content

Commit

Permalink
Merge pull request #46 from Kaaveh/ci/cd_pipeline
Browse files Browse the repository at this point in the history
Add CI/CD pipeline
  • Loading branch information
MohammadSianaki authored Jul 8, 2023
2 parents 7ad5557 + 71c63b9 commit e5993e6
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 47 deletions.
31 changes: 0 additions & 31 deletions .github/android_build.yml

This file was deleted.

48 changes: 48 additions & 0 deletions .github/workflows/build.yml
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
1 change: 1 addition & 0 deletions domain/market/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ android {
}

dependencies {
api(project(":library:core-test"))
implementation(KotlinxDependencies.coroutinesCore)
implementation(LifeCycleDependencies.lifeCycleViewModelKtx)
implementation(DIDependencies.javaxInject)
Expand Down
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()
}
}

}

0 comments on commit e5993e6

Please sign in to comment.