Interim while bringing sqlc in
This commit is contained in:
41
internal/domain64/database_test.go
Normal file
41
internal/domain64/database_test.go
Normal file
@@ -0,0 +1,41 @@
|
||||
package domain64
|
||||
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
_ "embed"
|
||||
"testing"
|
||||
|
||||
_ "modernc.org/sqlite"
|
||||
)
|
||||
|
||||
//go:embed schema.sql
|
||||
var ddl string
|
||||
|
||||
func setup() *sql.DB {
|
||||
ctx := context.Background()
|
||||
|
||||
db, err := sql.Open("sqlite", ":memory:")
|
||||
if err != nil {
|
||||
// TODO
|
||||
panic(err)
|
||||
}
|
||||
|
||||
// create tables
|
||||
if _, err := db.ExecContext(ctx, ddl); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return db
|
||||
}
|
||||
|
||||
func TestNewDomain64Map(t *testing.T) {
|
||||
db := setup()
|
||||
M, err := NewDomain64Map(db)
|
||||
if err != nil {
|
||||
// TODO
|
||||
t.Error(err)
|
||||
}
|
||||
if M.DB == nil {
|
||||
t.Error("DB should not be nil")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user