1
Fork 0

Remove loading env from tests. (#988)

* Remove loading env from tests.

* Rollback the test workflow.
This commit is contained in:
Googol Lee 2024-07-03 20:28:36 +02:00 committed by GitHub
parent 10e9e354b5
commit eab10af4a3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 12 additions and 20 deletions

View File

@ -1,10 +1,7 @@
package migrations_test package migrations_test
import ( import (
"bufio"
"math" "math"
"os"
"strings"
"testing" "testing"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
@ -15,23 +12,6 @@ import (
) )
func TestExifMigration(t *testing.T) { func TestExifMigration(t *testing.T) {
envFile, err := os.Open("/home/runner/work/photoview/photoview/api/testing.env")
if err != nil {
t.Fatalf("Failed to open environment file: %v", err)
}
defer envFile.Close()
scanner := bufio.NewScanner(envFile)
for scanner.Scan() {
line := scanner.Text()
parts := strings.SplitN(line, "=", 2)
if len(parts) != 2 {
t.Fatalf("Invalid line in environment file: %s", line)
}
key, value := parts[0], strings.Trim(parts[1], "'")
os.Setenv(key, value)
}
db := test_utils.DatabaseTest(t) db := test_utils.DatabaseTest(t)
defer db.Exec("DELETE FROM media_exif") // Clean up after test defer db.Exec("DELETE FROM media_exif") // Clean up after test

View File

@ -0,0 +1,12 @@
package migrations_test
import (
"os"
"testing"
"github.com/photoview/photoview/api/test_utils"
)
func TestMain(m *testing.M) {
os.Exit(test_utils.IntegrationTestRun(m))
}