Initial commit: email-openclaw bridge v1
Full pipeline: IMAP ingress -> OpenClaw dispatch -> callback -> SMTP reply. SQLite stateful storage with idempotency, threading, and retry logic. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
package database
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
// TestDB holds a test database instance with automatic cleanup.
|
||||
type TestDB struct {
|
||||
DB *gorm.DB
|
||||
cleanup func()
|
||||
}
|
||||
|
||||
// NewTestDB creates a temporary SQLite database for testing.
|
||||
func NewTestDB(t *testing.T) *TestDB {
|
||||
t.Helper()
|
||||
|
||||
dir := t.TempDir()
|
||||
dbPath := filepath.Join(dir, "test.db")
|
||||
|
||||
db, err := Open(dbPath)
|
||||
if err != nil {
|
||||
t.Fatalf("open test db: %v", err)
|
||||
}
|
||||
|
||||
return &TestDB{
|
||||
DB: db,
|
||||
cleanup: func() {
|
||||
os.RemoveAll(dir)
|
||||
},
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user