fix: Fix test workflow and Bleve test double-close panic

- Add POSTGRES_USER to PostgreSQL service configuration in test workflow
- Fix TestInitBleveIndex double-close panic by removing defer before explicit close
- Test now passes successfully

Fixes failing Unit Tests workflow in PR #64
This commit is contained in:
Damir Mukimov 2025-11-30 05:32:54 +01:00
parent 019aa78754
commit e63d627019
No known key found for this signature in database
GPG Key ID: 42996CC7C73BC750
2 changed files with 54 additions and 52 deletions

View File

@ -14,6 +14,7 @@ jobs:
postgres:
image: postgres:15
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: testdb
options: >-
@ -78,6 +79,7 @@ jobs:
postgres:
image: postgres:15
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: testdb
options: >-

View File

@ -8,11 +8,12 @@ import (
"testing"
"time"
"tercul/internal/domain"
"tercul/internal/platform/log"
"github.com/blevesearch/bleve/v2"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"tercul/internal/domain"
"tercul/internal/platform/log"
"gorm.io/gorm"
)
@ -189,10 +190,10 @@ func TestInitBleveIndex(t *testing.T) {
index1, err := initBleveIndex(indexPath)
require.NoError(t, err)
require.NotNil(t, index1)
defer index1.Close()
// Close and reopen
index1.Close()
// Close and reopen (don't use defer here since we're closing explicitly)
err = index1.Close()
require.NoError(t, err)
// Try to open existing index
index2, err := initBleveIndex(indexPath)
@ -434,4 +435,3 @@ func getTestLogger() *log.Logger {
log.Init("test", "test")
return log.FromContext(context.Background())
}