Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CI/CD pipeline #46

Merged
merged 3 commits into from
Jul 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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()
}
}

}