Skip to content

Commit bda1959

Browse files
Clean up some test code
1 parent 78acdf3 commit bda1959

File tree

1 file changed

+45
-9
lines changed

1 file changed

+45
-9
lines changed

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

Lines changed: 45 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,52 @@ class FeedDAOTest {
3434

3535
private val serviceId = ServiceList.YouTube.serviceId
3636

37-
private val stream1 = StreamEntity(1, serviceId, "https://youtube.com/watch?v=1", "stream 1", StreamType.VIDEO_STREAM, 1000, "channel-1", "https://youtube.com/channel/1", "https://i.ytimg.com/vi/1/hqdefault.jpg", 100, "2023-01-01", Instant.parse("2023-01-01T00:00:00Z"))
38-
private val stream2 = StreamEntity(2, serviceId, "https://youtube.com/watch?v=2", "stream 2", StreamType.VIDEO_STREAM, 1000, "channel-1", "https://youtube.com/channel/1", "https://i.ytimg.com/vi/1/hqdefault.jpg", 100, "2023-01-02", Instant.parse("2023-01-02T00:00:00Z"))
39-
private val stream3 = StreamEntity(3, serviceId, "https://youtube.com/watch?v=3", "stream 3", StreamType.LIVE_STREAM, 1000, "channel-1", "https://youtube.com/channel/1", "https://i.ytimg.com/vi/1/hqdefault.jpg", 100, "2023-01-03", Instant.parse("2023-01-03T00:00:00Z"))
40-
private val stream4 = StreamEntity(4, serviceId, "https://youtube.com/watch?v=4", "stream 4", StreamType.VIDEO_STREAM, 1000, "channel-2", "https://youtube.com/channel/2", "https://i.ytimg.com/vi/1/hqdefault.jpg", 100, "2023-08-10", Instant.parse("2023-08-10T00:00:00Z"))
41-
private val stream5 = StreamEntity(5, serviceId, "https://youtube.com/watch?v=5", "stream 5", StreamType.VIDEO_STREAM, 1000, "channel-2", "https://youtube.com/channel/2", "https://i.ytimg.com/vi/1/hqdefault.jpg", 100, "2023-08-20", Instant.parse("2023-08-20T00:00:00Z"))
42-
private val stream6 = StreamEntity(6, serviceId, "https://youtube.com/watch?v=6", "stream 6", StreamType.VIDEO_STREAM, 1000, "channel-3", "https://youtube.com/channel/3", "https://i.ytimg.com/vi/1/hqdefault.jpg", 100, "2023-09-01", Instant.parse("2023-09-01T00:00:00Z"))
43-
private val stream7 = StreamEntity(7, serviceId, "https://youtube.com/watch?v=7", "stream 7", StreamType.VIDEO_STREAM, 1000, "channel-4", "https://youtube.com/channel/4", "https://i.ytimg.com/vi/1/hqdefault.jpg", 100, "2023-08-10", Instant.parse("2023-08-10T00:00:00Z"))
37+
private val stream1 =
38+
createStreamEntity(
39+
1, "https://youtube.com/watch?v=1", "stream 1", uploader = "channel-1",
40+
uploaderUrl = "https://youtube.com/channel/1", date = LocalDate.of(2023, Month.JANUARY, 2),
41+
)
42+
private val stream2 =
43+
createStreamEntity(
44+
2, "https://youtube.com/watch?v=2", "stream 2", uploader = "channel-1",
45+
uploaderUrl = "https://youtube.com/channel/1", date = LocalDate.of(2023, Month.JANUARY, 2),
46+
)
47+
private val stream3 =
48+
createStreamEntity(
49+
3, "https://youtube.com/watch?v=3", "stream 3", StreamType.LIVE_STREAM,
50+
"channel-1", "https://youtube.com/channel/1", LocalDate.of(2023, Month.JANUARY, 3),
51+
)
52+
private val stream4 =
53+
createStreamEntity(
54+
4, "https://youtube.com/watch?v=4", "stream 4", uploader = "channel-2",
55+
uploaderUrl = "https://youtube.com/channel/2", date = LocalDate.of(2023, Month.AUGUST, 10),
56+
)
57+
private val stream5 =
58+
createStreamEntity(
59+
5, "https://youtube.com/watch?v=5", "stream 5", uploader = "channel-2",
60+
uploaderUrl = "https://youtube.com/channel/2", date = LocalDate.of(2023, Month.AUGUST, 20),
61+
)
62+
private val stream6 =
63+
createStreamEntity(
64+
6, "https://youtube.com/watch?v=6", "stream 6", uploader = "channel-3",
65+
uploaderUrl = "https://youtube.com/channel/3", date = LocalDate.of(2023, Month.SEPTEMBER, 1),
66+
)
67+
private val stream7 =
68+
createStreamEntity(
69+
7, "https://youtube.com/watch?v=7", "stream 7", uploader = "channel-4",
70+
uploaderUrl = "https://youtube.com/channel/4", date = LocalDate.of(2023, Month.AUGUST, 10),
71+
)
72+
73+
private val allStreams = listOf(stream1, stream2, stream3, stream4, stream5, stream6, stream7)
4474

45-
private val allStreams = listOf(
46-
stream1, stream2, stream3, stream4, stream5, stream6, stream7
75+
private fun createStreamEntity(
76+
uid: Long, url: String, title: String, type: StreamType = StreamType.VIDEO_STREAM,
77+
uploader: String, uploaderUrl: String, date: LocalDate,
78+
) = StreamEntity(
79+
uid, serviceId, url, title, type, duration = 1000, uploader, uploaderUrl,
80+
"https://i.ytimg.com/vi/1/hqdefault.jpg",
81+
viewCount = 100, date.toString(),
82+
date.atStartOfDay(ZoneOffset.UTC).toInstant(),
4783
)
4884

4985
@Before

0 commit comments

Comments
 (0)