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

Function TestMigrate_sqlError

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

Source from the content-addressed store, hash-verified

219}
220
221func TestMigrate_sqlError(t *testing.T) {
222 db, err := gorm.Open(sqlite.Open(":memory:"), &gorm.Config{})
223 if err != nil {
224 t.Fatalf("failed to open database: %v", err)
225 }
226
227 // Create migration with invalid SQL
228 migrationsFs := fstest.MapFS{
229 "001-bad-sql.sql": &fstest.MapFile{
230 Data: []byte("INVALID SQL SYNTAX HERE;"),
231 },
232 }
233
234 // Should return error for SQL execution failure
235 err = migrate(db, migrationsFs)
236 if err == nil {
237 t.Fatal("expected error for invalid SQL, got nil")
238 }
239}
240
241func TestMigrate_emptyFile(t *testing.T) {
242 db, err := gorm.Open(sqlite.Open(":memory:"), &gorm.Config{})

Callers

nothing calls this directly

Calls 2

migrateFunction · 0.85
OpenMethod · 0.80

Tested by

no test coverage detected