feat: Integrate Mokkery and Turbine into KMP testing framework (#4845)

This commit is contained in:
James Rich 2026-03-18 18:33:37 -05:00 committed by GitHub
parent df3a094430
commit dcbbc0823b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
159 changed files with 1860 additions and 2809 deletions

View file

@ -17,6 +17,7 @@
package org.meshtastic.core.repository
import kotlinx.coroutines.flow.StateFlow
import org.meshtastic.core.common.UiPreferences
/** Reactive interface for analytics-related preferences. */
interface AnalyticsPrefs {
@ -180,6 +181,7 @@ interface AppPreferences {
val meshLog: MeshLogPrefs
val emoji: CustomEmojiPrefs
val ui: UiPrefs
val uiPrefs: UiPreferences
val map: MapPrefs
val mapConsent: MapConsentPrefs
val mapTileProvider: MapTileProviderPrefs

View file

@ -0,0 +1,32 @@
/*
* Copyright (c) 2026 Meshtastic LLC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package org.meshtastic.core.repository
import kotlinx.coroutines.flow.Flow
import org.meshtastic.core.database.entity.QuickChatAction
interface QuickChatActionRepository {
fun getAllActions(): Flow<List<QuickChatAction>>
suspend fun upsert(action: QuickChatAction)
suspend fun deleteAll()
suspend fun delete(action: QuickChatAction)
suspend fun setItemPosition(uuid: Long, newPos: Int)
}

View file

@ -25,6 +25,7 @@ import org.meshtastic.core.repository.MessageQueue
import org.meshtastic.core.repository.NodeRepository
import org.meshtastic.core.repository.PacketRepository
import org.meshtastic.core.repository.usecase.SendMessageUseCase
import org.meshtastic.core.repository.usecase.SendMessageUseCaseImpl
@Module
class CoreRepositoryModule {
@ -36,5 +37,5 @@ class CoreRepositoryModule {
@Provided homoglyphEncodingPrefs: HomoglyphPrefs,
@Provided messageQueue: MessageQueue,
): SendMessageUseCase =
SendMessageUseCase(nodeRepository, packetRepository, radioController, homoglyphEncodingPrefs, messageQueue)
SendMessageUseCaseImpl(nodeRepository, packetRepository, radioController, homoglyphEncodingPrefs, messageQueue)
}

View file

@ -43,14 +43,18 @@ import kotlin.random.Random
*
* This implementation is platform-agnostic and relies on injected repositories and controllers.
*/
interface SendMessageUseCase {
suspend operator fun invoke(text: String, contactKey: String = "0${DataPacket.ID_BROADCAST}", replyId: Int? = null)
}
@Suppress("TooGenericExceptionCaught")
class SendMessageUseCase(
class SendMessageUseCaseImpl(
private val nodeRepository: NodeRepository,
private val packetRepository: PacketRepository,
private val radioController: RadioController,
private val homoglyphEncodingPrefs: HomoglyphPrefs,
private val messageQueue: MessageQueue,
) {
) : SendMessageUseCase {
/**
* Executes the send message workflow.
@ -60,11 +64,7 @@ class SendMessageUseCase(
* @param replyId Optional ID of a message being replied to.
*/
@Suppress("NestedBlockDepth", "LongMethod", "CyclomaticComplexMethod")
suspend operator fun invoke(
text: String,
contactKey: String = "0${DataPacket.ID_BROADCAST}",
replyId: Int? = null,
) {
override suspend operator fun invoke(text: String, contactKey: String, replyId: Int?) {
val channel = contactKey[0].digitToIntOrNull()
val dest = if (channel != null) contactKey.substring(1) else contactKey