chore: remove cached
This commit is contained in:
@@ -1,18 +0,0 @@
|
||||
package database
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"gorm.io/driver/sqlite"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
// Connect opens a SQLite database connection.
|
||||
func Connect(dbPath string) (*gorm.DB, error) {
|
||||
db, err := gorm.Open(sqlite.Open(dbPath), &gorm.Config{})
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("open database: %w", err)
|
||||
}
|
||||
|
||||
return db, nil
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
package database
|
||||
|
||||
import (
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestConnect(t *testing.T) {
|
||||
// Test with memory DB
|
||||
db, err := Connect("file::memory:?cache=shared")
|
||||
assert.NoError(t, err)
|
||||
assert.NotNil(t, db)
|
||||
|
||||
// Test with file DB
|
||||
tempDir := t.TempDir()
|
||||
dbPath := filepath.Join(tempDir, "test.db")
|
||||
db, err = Connect(dbPath)
|
||||
assert.NoError(t, err)
|
||||
assert.NotNil(t, db)
|
||||
}
|
||||
|
||||
func TestConnect_Error(t *testing.T) {
|
||||
// Test with invalid path (directory)
|
||||
tempDir := t.TempDir()
|
||||
_, err := Connect(tempDir)
|
||||
assert.Error(t, err)
|
||||
}
|
||||
Reference in New Issue
Block a user