From d6e01b23be1128db7fd4a10cc3fa7a7499950f3d Mon Sep 17 00:00:00 2001 From: GitHub Actions Date: Tue, 17 Feb 2026 07:31:03 +0000 Subject: [PATCH] fix: update readFixture to use dynamic path for testdata directory --- backend/internal/crowdsec/hub_sync_test.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/backend/internal/crowdsec/hub_sync_test.go b/backend/internal/crowdsec/hub_sync_test.go index e35a8dc1..fae57338 100644 --- a/backend/internal/crowdsec/hub_sync_test.go +++ b/backend/internal/crowdsec/hub_sync_test.go @@ -12,6 +12,7 @@ import ( "net/http/httptest" "os" "path/filepath" + "runtime" "sort" "strings" "testing" @@ -73,8 +74,10 @@ func makeTarGz(t *testing.T, files map[string]string) []byte { func readFixture(t *testing.T, name string) string { t.Helper() + _, currentFile, _, ok := runtime.Caller(0) + require.True(t, ok) // #nosec G304 -- Test reads from testdata directory with known fixture names - data, err := os.ReadFile(filepath.Join("testdata", name)) + data, err := os.ReadFile(filepath.Join(filepath.Dir(currentFile), "testdata", name)) require.NoError(t, err) return string(data) }