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

Function TestMigrate_emptyFile

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

Source from the content-addressed store, hash-verified

239}
240
241func TestMigrate_emptyFile(t *testing.T) {
242 db, err := gorm.Open(sqlite.Open(":memory:"), &gorm.Config{})
243 if err != nil {
244 t.Fatalf("failed to open database: %v", err)
245 }
246
247 tests := []struct {
248 name string
249 data string
250 wantErr bool
251 }{
252 {"completely empty", "", true},
253 {"only whitespace", " \n\t ", true},
254 {"only comments", "-- just a comment", false},
255 }
256
257 for _, tt := range tests {
258 t.Run(tt.name, func(t *testing.T) {
259 migrationsFs := fstest.MapFS{
260 "001-empty.sql": &fstest.MapFile{
261 Data: []byte(tt.data),
262 },
263 }
264
265 err = migrate(db, migrationsFs)
266 if (err != nil) != tt.wantErr {
267 t.Errorf("error = %v, wantErr %v", err, tt.wantErr)
268 }
269 })
270 }
271}
272
273func TestMigrate_invalidFilename(t *testing.T) {
274 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