mirror of
https://github.com/dnote/dnote
synced 2026-03-15 06:55:49 +01:00
27 lines
668 B
Go
27 lines
668 B
Go
package database
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
func TestSchemaEmbed(t *testing.T) {
|
|
db := InitTestMemoryDB(t)
|
|
defer db.Close()
|
|
|
|
// Try to insert a book to verify schema is loaded
|
|
_, err := db.Exec("INSERT INTO books (uuid, label) VALUES (?, ?)", "test-uuid", "test-label")
|
|
if err != nil {
|
|
t.Fatalf("Failed to insert into books: %v", err)
|
|
}
|
|
|
|
// Verify it was inserted
|
|
var label string
|
|
err = db.QueryRow("SELECT label FROM books WHERE uuid = ?", "test-uuid").Scan(&label)
|
|
if err != nil {
|
|
t.Fatalf("Failed to query books: %v", err)
|
|
}
|
|
if label != "test-label" {
|
|
t.Fatalf("Expected label 'test-label', got '%s'", label)
|
|
}
|
|
t.Log("Schema embed test passed!")
|
|
}
|