feat(admin): initialize procurement service skeleton

This commit is contained in:
QiuSW
2026-08-03 18:13:30 +08:00
parent b7559a9451
commit c72371ce90
11 changed files with 288 additions and 37 deletions
+13
View File
@@ -0,0 +1,13 @@
// Package sqlite 提供采购服务的 SQLite 驱动注册。
package sqlite
import (
"database/sql"
_ "github.com/mattn/go-sqlite3"
)
// Open 打开 SQLite 数据源;调用方负责其 schema 与生命周期。
func Open(dataSourceName string) (*sql.DB, error) {
return sql.Open("sqlite3", dataSourceName)
}
@@ -0,0 +1,24 @@
package sqlite_test
import (
"context"
"testing"
"cmbuyer/admin/internal/storage/sqlite"
)
func TestOpen(t *testing.T) {
database, err := sqlite.Open(":memory:")
if err != nil {
t.Fatalf("open SQLite database: %v", err)
}
t.Cleanup(func() {
if err := database.Close(); err != nil {
t.Errorf("close SQLite database: %v", err)
}
})
if err := database.PingContext(context.Background()); err != nil {
t.Fatalf("ping SQLite database: %v", err)
}
}