Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ object TasksFetcher {
val title = cursor.getString(titleIdx) ?: context.getString(R.string.widget_no_title)
tasks.add(TaskData(title, dueMillis))
}
}
} ?: return null
} catch (e: Exception) {
android.util.Log.w("TasksFetcher", "Failed to read Tasks.org tasks", e)
return null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.leanbitlab.lwidget.tasks
import android.content.Context
import androidx.test.core.app.ApplicationProvider
import org.junit.Assert.assertEquals
import org.junit.Assert.assertNull
import org.junit.runner.RunWith
import org.robolectric.RobolectricTestRunner
import org.robolectric.annotation.Config
Expand All @@ -15,6 +16,12 @@ class TasksFetcherTest {

private val context: Context = ApplicationProvider.getApplicationContext()

@Test
fun testUnreachableProviderIsNotReportedAsNoTasks() {
// No org.tasks provider is registered, so query() returns null
assertNull(TasksFetcher.fetchActiveTasks(context, 5))
}

@Test
fun testFormatDueSuffixZeroOrNegative() {
assertEquals("", TasksFetcher.formatDueSuffix(context, 0L))
Expand Down
Loading