MCPcopy Create free account
hub / github.com/astercloud/aster / TestDatabaseFileCreation

Function TestDatabaseFileCreation

pkg/session/sqlite/store_test.go:463–486  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

461}
462
463func TestDatabaseFileCreation(t *testing.T) {
464 tmpDir := t.TempDir()
465 dbPath := filepath.Join(tmpDir, "subdir", "test.db")
466
467 // Should fail because parent directory doesn't exist
468 _, err := New(dbPath)
469 if err == nil {
470 t.Error("Should fail when parent directory doesn't exist")
471 }
472
473 // Create parent directory
474 _ = os.MkdirAll(filepath.Dir(dbPath), 0755)
475
476 svc, err := New(dbPath)
477 if err != nil {
478 t.Fatalf("New should succeed after creating parent dir: %v", err)
479 }
480 _ = svc.Close()
481
482 // Verify file exists
483 if _, err := os.Stat(dbPath); os.IsNotExist(err) {
484 t.Error("Database file should be created")
485 }
486}

Callers

nothing calls this directly

Calls 5

NewFunction · 0.70
ErrorMethod · 0.65
CloseMethod · 0.65
StatMethod · 0.65
JoinMethod · 0.45

Tested by

no test coverage detected