Snapshot: Filtro de data corrigido para dd/mm/aa
This commit is contained in:
69
app/src/test/java/com/example/ExampleRobolectricTest.kt
Normal file
69
app/src/test/java/com/example/ExampleRobolectricTest.kt
Normal file
@@ -0,0 +1,69 @@
|
||||
package com.example
|
||||
|
||||
import android.content.Context
|
||||
import androidx.test.core.app.ApplicationProvider
|
||||
import com.example.data.local.AppDatabase
|
||||
import com.example.data.remote.GoogleSheetsSyncService
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.robolectric.RobolectricTestRunner
|
||||
import org.robolectric.annotation.Config
|
||||
|
||||
import kotlinx.coroutines.flow.first
|
||||
|
||||
@RunWith(RobolectricTestRunner::class)
|
||||
@Config(sdk = [34])
|
||||
class ExampleRobolectricTest {
|
||||
|
||||
@Test
|
||||
fun `read string from context`() {
|
||||
val context = ApplicationProvider.getApplicationContext<Context>()
|
||||
val appName = context.getString(R.string.app_name)
|
||||
assertEquals("Cargill Parada OS", appName)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `inspect project sheet`() {
|
||||
val context = ApplicationProvider.getApplicationContext<Context>()
|
||||
val service = GoogleSheetsSyncService(context)
|
||||
println("--- INSPECTING PROJECT SHEET ---")
|
||||
try {
|
||||
val values = service.fetchValues("project!A1:Z50")
|
||||
println("Fetched ${values.size} rows with columns up to Z")
|
||||
for ((index, row) in values.withIndex()) {
|
||||
println("Row $index: $row")
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
println("Failed to fetch sheet: ${e.message}")
|
||||
e.printStackTrace()
|
||||
}
|
||||
println("--- END INSPECTING ---")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `diagnose synchronization backend`() {
|
||||
val context = ApplicationProvider.getApplicationContext<Context>()
|
||||
val db = androidx.room.Room.inMemoryDatabaseBuilder(context, AppDatabase::class.java).build()
|
||||
val repository = com.example.data.repository.MaintenanceRepository(db.maintenanceDao(), context)
|
||||
|
||||
println("--- STARTING SYNCHRONIZE DIAGNOSTIC UPDATED ---")
|
||||
try {
|
||||
val result = kotlinx.coroutines.runBlocking {
|
||||
val r = repository.synchronizeWithBackend()
|
||||
println("Sync Result: $r")
|
||||
val list = repository.allActivities.first()
|
||||
println("Total activities in database: ${list.size}")
|
||||
list.forEach { act ->
|
||||
println(" OS: ${act.numeroOs}, Desc: ${act.descricao}, Setor: ${act.setor}, Equipe: ${act.equipe}, Pct: ${act.percentualExecucao}")
|
||||
}
|
||||
r
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
println("Sync threw exception: ${e.message}")
|
||||
e.printStackTrace()
|
||||
}
|
||||
println("--- END SYNCHRONIZE DIAGNOSTIC ---")
|
||||
db.close()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user