Skip to content

Commit

Permalink
Issue mozilla-mobile#8751: Added DAO method to update top site entries
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzos committed Oct 26, 2020
1 parent f57c1bf commit afca80f
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,30 @@ class PinnedSiteDaoTest {
assertEquals(1, pinnedSites.size)
assertEquals(topSite, pinnedSites[0])
}

@Test
fun testUpdatingTopSite() {
val topSite = PinnedSiteEntity(
title = "Mozilla",
url = "https://www.mozilla.org",
isDefault = false,
createdAt = 200
).also {
it.id = pinnedSiteDao.insertPinnedSite(it)
}

topSite.title = "Mozilla (IT)"
topSite.url = "https://www.mozilla.org/it"
pinnedSiteDao.updatePinnedSite(topSite)

val pinnedSites = pinnedSiteDao.getPinnedSites()

assertEquals(1, pinnedSites.size)
assertEquals(topSite, pinnedSites[0])
assertEquals(topSite.title, pinnedSites[0].title)
assertEquals(topSite.url, pinnedSites[0].url)

}

@Test
fun testRemovingTopSite() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,7 @@
package mozilla.components.feature.top.sites.db

import androidx.annotation.WorkerThread
import androidx.room.Dao
import androidx.room.Delete
import androidx.room.Insert
import androidx.room.Query
import androidx.room.Transaction
import androidx.room.*

/**
* Internal DAO for accessing [PinnedSiteEntity] instances.
Expand All @@ -20,6 +16,10 @@ internal interface PinnedSiteDao {
@Insert
fun insertPinnedSite(site: PinnedSiteEntity): Long

@WorkerThread
@Update
fun updatePinnedSite(site: PinnedSiteEntity)

@WorkerThread
@Delete
fun deletePinnedSite(site: PinnedSiteEntity)
Expand Down

0 comments on commit afca80f

Please sign in to comment.