test(go): set GOPATH for tests (#9785)

This commit is contained in:
DmitriyLewen
2025-11-12 13:44:41 +06:00
committed by GitHub
parent 6048173266
commit 3a2a31d45a

View File

@@ -3,6 +3,7 @@ package mod
import ( import (
"sort" "sort"
"testing" "testing"
"testing/fstest"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
@@ -345,6 +346,8 @@ func Test_gomodAnalyzer_Analyze(t *testing.T) {
// Set GOPATH fs.FS for testing // Set GOPATH fs.FS for testing
ma := a.(*gomodAnalyzer) ma := a.(*gomodAnalyzer)
// Use empty fs.FS to simulate no GOPATH scenario
ma.gopathFS = fstest.MapFS{}
if tt.gopath { if tt.gopath {
ma.gopathFS = gopathFS ma.gopathFS = gopathFS
} }