MCPcopy Index your code
hub / github.com/dnote/dnote / TestMigrate_initTableError

Function TestMigrate_initTableError

pkg/server/database/migrate_test.go:185–206  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

183}
184
185func TestMigrate_initTableError(t *testing.T) {
186 db, err := gorm.Open(sqlite.Open(":memory:"), &gorm.Config{})
187 if err != nil {
188 t.Fatalf("failed to open database: %v", err)
189 }
190
191 // Close the database connection to cause exec to fail
192 sqlDB, _ := db.DB()
193 sqlDB.Close()
194
195 migrationsFs := fstest.MapFS{
196 "001-init.sql": &fstest.MapFile{
197 Data: []byte("SELECT 1;"),
198 },
199 }
200
201 // Should return error for table initialization failure
202 err = migrate(db, migrationsFs)
203 if err == nil {
204 t.Fatal("expected error for table initialization failure, got nil")
205 }
206}
207
208func TestMigrate_readDirError(t *testing.T) {
209 db, err := gorm.Open(sqlite.Open(":memory:"), &gorm.Config{})

Callers

nothing calls this directly

Calls 3

migrateFunction · 0.85
OpenMethod · 0.80
CloseMethod · 0.65

Tested by

no test coverage detected