Room Database Setup
This commit is contained in:
parent
7190b1574d
commit
793600dd5a
@ -1,31 +0,0 @@
|
||||
package com.example.notebook.data
|
||||
|
||||
import android.content.Context
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
/**
|
||||
* Helper untuk test database
|
||||
* Panggil fungsi ini dari MainActivity untuk test
|
||||
*/
|
||||
class DatabaseTest(private val context: Context) {
|
||||
|
||||
private val database = AppDatabase.getDatabase(context)
|
||||
private val dao = database.notebookDao()
|
||||
|
||||
fun testInsertNotebook() {
|
||||
CoroutineScope(Dispatchers.IO).launch {
|
||||
val testNotebook = NotebookEntity(
|
||||
title = "Notebook Test",
|
||||
description = "Ini adalah test database",
|
||||
createdAt = System.currentTimeMillis(),
|
||||
updatedAt = System.currentTimeMillis(),
|
||||
sourceCount = 0
|
||||
)
|
||||
|
||||
val id = dao.insertNotebook(testNotebook)
|
||||
println("✅ Database Test: Notebook berhasil disimpan dengan ID: $id")
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user