added test (#5)

Reviewed-on: phoenix/textsender-auth#5
Co-authored-by: phoenix <kundeng00@pm.me>
Co-committed-by: phoenix <kundeng00@pm.me>
This commit is contained in:
phoenix
2025-09-12 18:30:15 +00:00
committed by phoenix
parent 6f819eff16
commit 976a017b4f
9 changed files with 319 additions and 10 deletions
+8 -1
View File
@@ -6,6 +6,7 @@ import (
"fmt"
"log"
"os"
"path"
"strings"
"time"
@@ -82,7 +83,13 @@ func (db *Database) ResetDatabase(ctx context.Context) error {
schemaContent, err := os.ReadFile("migrations/schema.sql")
if err != nil {
return fmt.Errorf("error reading schema file: %v", err)
log.Println("Default migrations not found. Checking different directory")
cwd, _ := os.Getwd()
migrationsPath := path.Join(cwd, "../..", "migrations/schema.sql")
schemaContent, err = os.ReadFile(migrationsPath)
if err != nil {
return fmt.Errorf("error reading schema file: %v", err)
}
}
statements := strings.Split(string(schemaContent), ";")