test: activate dead NodeInfoDao tests (#6113)

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
James Rich
2026-07-06 10:13:24 -05:00
committed by GitHub
parent 9c4db49300
commit 4ea3f27e8c
2 changed files with 32 additions and 0 deletions

View File

@@ -0,0 +1,25 @@
/*
* 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.database.dao
import androidx.test.ext.junit.runners.AndroidJUnit4
import org.junit.runner.RunWith
import org.robolectric.annotation.Config
@RunWith(AndroidJUnit4::class)
@Config(sdk = [34])
class NodeInfoDaoTest : CommonNodeInfoDaoTest()

View File

@@ -23,6 +23,7 @@ import org.meshtastic.core.database.MeshtasticDatabase
import org.meshtastic.core.database.entity.MyNodeEntity
import org.meshtastic.core.database.entity.NodeEntity
import org.meshtastic.core.database.getInMemoryDatabaseBuilder
import org.meshtastic.core.testing.setupTestContext
import org.meshtastic.proto.User
import kotlin.test.AfterTest
import kotlin.test.Test
@@ -49,6 +50,7 @@ abstract class CommonNodeInfoDaoTest {
)
suspend fun createDb() {
setupTestContext()
database = getInMemoryDatabaseBuilder().build()
dao = database.nodeInfoDao()
dao.setMyNodeInfo(myNodeInfo)
@@ -61,6 +63,7 @@ abstract class CommonNodeInfoDaoTest {
@Test
fun testGetMyNodeInfo() = runTest {
createDb()
val info = dao.getMyNodeInfo().first()
assertNotNull(info)
assertEquals(myNodeInfo.myNodeNum, info.myNodeNum)
@@ -68,6 +71,7 @@ abstract class CommonNodeInfoDaoTest {
@Test
fun testUpsertNode() = runTest {
createDb()
val node =
NodeEntity(
num = 1234,
@@ -82,6 +86,7 @@ abstract class CommonNodeInfoDaoTest {
@Test
fun testNodeDBbyNum() = runTest {
createDb()
val node1 = NodeEntity(num = 1, user = User(id = "!1"))
val node2 = NodeEntity(num = 2, user = User(id = "!2"))
dao.putAll(listOf(node1, node2))
@@ -94,6 +99,7 @@ abstract class CommonNodeInfoDaoTest {
@Test
fun testDeleteNode() = runTest {
createDb()
val node = NodeEntity(num = 1, user = User(id = "!1"))
dao.upsert(node)
dao.deleteNode(1)
@@ -103,6 +109,7 @@ abstract class CommonNodeInfoDaoTest {
@Test
fun testClearNodeInfo() = runTest {
createDb()
val node1 = NodeEntity(num = 1, user = User(id = "!1"), isFavorite = true)
val node2 = NodeEntity(num = 2, user = User(id = "!2"), isFavorite = false)
dao.putAll(listOf(node1, node2))