Coverage Summary for Class: DeleteSavingsGoalUseCase (com.georgeci.moneysurfer.domain.usecase)

Class Method, % Branch, % Line, % Instruction, %
DeleteSavingsGoalUseCase 100% (2/2) 100% (2/2) 100% (5/5) 100% (45/45)
DeleteSavingsGoalUseCase$invoke$1
Total 100% (2/2) 100% (2/2) 100% (5/5) 100% (45/45)


 package com.georgeci.moneysurfer.domain.usecase
 
 import com.georgeci.moneysurfer.domain.model.SavingsGoal
 import com.georgeci.moneysurfer.domain.primitives.GoalId
 import com.georgeci.moneysurfer.domain.repositories.SavingsGoalRepository
 import org.koin.core.annotation.Single
 
 /**
  * Hard-deletes a goal and its contributions. Archiving is the reversible option —
  * this one is for "remove it for good".
  */
 @Single
 class DeleteSavingsGoalUseCase(
     private val goalRepository: SavingsGoalRepository,
 ) {
 
     /** Returns the removed goal, or `null` when there was nothing to remove. */
     suspend operator fun invoke(id: GoalId): SavingsGoal? {
         val existing = goalRepository.getById(id) ?: return null
         goalRepository.delete(id)
         return existing
     }
 }