From 2cd35ea84a9560ea717c9a057657a99305d54bd6 Mon Sep 17 00:00:00 2001 From: Stephen Adamson Date: Fri, 10 Jul 2026 18:45:18 +0100 Subject: [PATCH] fix: S3-dependent tests skip in prod, add GO_TESTING to CI for dav init --- .gitea/workflows/ci.yaml | 1 + backend/handlers/portfolio/images_test.go | 5 +++++ backend/handlers/user/profile_test.go | 9 +++++++++ 3 files changed, 15 insertions(+) diff --git a/.gitea/workflows/ci.yaml b/.gitea/workflows/ci.yaml index d82066c..6fdc11c 100644 --- a/.gitea/workflows/ci.yaml +++ b/.gitea/workflows/ci.yaml @@ -451,6 +451,7 @@ jobs: working-directory: backend run: go test -tags "${{ matrix.gotags }}" -count=1 ${{ matrix.verbose }} ${{ matrix.coverflags }} ./... env: + GO_TESTING: "1" POSTGRES_HOST: postgres TEST_DB_HOST: postgres diff --git a/backend/handlers/portfolio/images_test.go b/backend/handlers/portfolio/images_test.go index 5709033..4454144 100644 --- a/backend/handlers/portfolio/images_test.go +++ b/backend/handlers/portfolio/images_test.go @@ -26,6 +26,7 @@ import ( "strings" "testing" + "crussell/internal/s3" "crussell/mw" "crussell/testutils" @@ -1433,6 +1434,10 @@ func jxlBytes() []byte { // TestPortfolio_Upload_Success verifies a successful image upload with mock S3, // testing the full flow: multipart form parsing, S3 upload, DB insert, and response. func TestPortfolio_Upload_Success(t *testing.T) { + if s3.Client == nil { + t.Skip("S3 client not initialized (requires R2_ENDPOINT)") + } + ctx, _ := testutils.SetupTestTx(t) jpeg := jpegBytes(t) diff --git a/backend/handlers/user/profile_test.go b/backend/handlers/user/profile_test.go index 94b83a0..bb10e68 100644 --- a/backend/handlers/user/profile_test.go +++ b/backend/handlers/user/profile_test.go @@ -29,6 +29,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "crussell/internal/s3" "crussell/mw" "crussell/testutils" "crussell/testutils/fixtures" @@ -1226,6 +1227,10 @@ func TestProcessProfileImage_InvalidImage(t *testing.T) { // ============================================================================= func TestUploadProfilePicture_Success(t *testing.T) { + if s3.Client == nil { + t.Skip("S3 client not initialized (requires R2_ENDPOINT)") + } + ctx, tx := testutils.SetupTestTx(t) userID, err := fixtures.CreateTestUser(tx) @@ -1291,6 +1296,10 @@ func TestUploadProfilePicture_NoAuth(t *testing.T) { } func TestUploadProfilePicture_NotImage(t *testing.T) { + if s3.Client == nil { + t.Skip("S3 client not initialized (requires R2_ENDPOINT)") + } + ctx, tx := testutils.SetupTestTx(t) userID, err := fixtures.CreateTestUser(tx)