Set Test environment in tests

This commit is contained in:
2025-08-10 21:01:18 +02:00
parent 1880051165
commit 84158683cd
10 changed files with 346 additions and 18 deletions
+11
View File
@@ -5,6 +5,7 @@ import (
"encoding/json"
"net/http"
"net/http/httptest"
"os"
"testing"
"bamort/database"
@@ -15,6 +16,16 @@ import (
)
func TestImproveSkillHandler(t *testing.T) {
// Setup test environment
original := os.Getenv("ENVIRONMENT")
os.Setenv("ENVIRONMENT", "test")
t.Cleanup(func() {
if original != "" {
os.Setenv("ENVIRONMENT", original)
} else {
os.Unsetenv("ENVIRONMENT")
}
})
// Setup test database
database.SetupTestDB(true, true)
defer database.ResetTestDB()