Skip to content

Commit 15fd47c

Browse files
committed
Apply review
1 parent ef40ac7 commit 15fd47c

1 file changed

Lines changed: 11 additions & 5 deletions

File tree

app/src/androidTest/java/org/schabi/newpipe/database/DatabaseMigrationTest.kt

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import org.junit.Assert.assertNull
1313
import org.junit.Rule
1414
import org.junit.Test
1515
import org.junit.runner.RunWith
16+
import org.schabi.newpipe.extractor.ServiceList
1617
import org.schabi.newpipe.extractor.stream.StreamType
1718

1819
@RunWith(AndroidJUnit4::class)
@@ -26,7 +27,7 @@ class DatabaseMigrationTest {
2627
private const val DEFAULT_UPLOADER_NAME = "Uploader Test"
2728
private const val DEFAULT_THUMBNAIL = "https://example.com/example.jpg"
2829

29-
private const val DEFAULT_SECOND_SERVICE_ID = 1
30+
private const val DEFAULT_SECOND_SERVICE_ID = 0
3031
private const val DEFAULT_SECOND_URL = "https://www.youtube.com/watch?v=ncQU6iBn5Fc"
3132
}
3233

@@ -155,32 +156,37 @@ class DatabaseMigrationTest {
155156
val defaultSearch1 = " abc "
156157
val defaultSearch2 = " abc"
157158

159+
val serviceId = DEFAULT_SERVICE_ID // YouTube
160+
// Use id different to YouTube because two searches with the same query
161+
// but different service are considered not equal.
162+
val otherServiceId = ServiceList.SoundCloud.serviceId
163+
158164
databaseInV7.run {
159165
insert(
160166
"search_history", SQLiteDatabase.CONFLICT_FAIL,
161167
ContentValues().apply {
162-
put("service_id", DEFAULT_SERVICE_ID)
168+
put("service_id", serviceId)
163169
put("search", defaultSearch1)
164170
}
165171
)
166172
insert(
167173
"search_history", SQLiteDatabase.CONFLICT_FAIL,
168174
ContentValues().apply {
169-
put("service_id", DEFAULT_SERVICE_ID)
175+
put("service_id", serviceId)
170176
put("search", defaultSearch2)
171177
}
172178
)
173179
insert(
174180
"search_history", SQLiteDatabase.CONFLICT_FAIL,
175181
ContentValues().apply {
176-
put("service_id", DEFAULT_SECOND_SERVICE_ID)
182+
put("service_id", otherServiceId)
177183
put("search", defaultSearch1)
178184
}
179185
)
180186
insert(
181187
"search_history", SQLiteDatabase.CONFLICT_FAIL,
182188
ContentValues().apply {
183-
put("service_id", DEFAULT_SECOND_SERVICE_ID)
189+
put("service_id", otherServiceId)
184190
put("search", defaultSearch2)
185191
}
186192
)

0 commit comments

Comments
 (0)