Skip to content

Commit 514da84

Browse files
authored
Merge pull request #1928 from elezar/cherry-pick-testdata-changes
Cherry pick testdata changes
2 parents cce709f + 6c5604e commit 514da84

File tree

265 files changed

+8
-9
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

265 files changed

+8
-9
lines changed

source/pci/pci_test.go

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ package pci
1818

1919
import (
2020
"path/filepath"
21-
"runtime"
2221
"testing"
2322

2423
"github.com/stretchr/testify/assert"
@@ -27,13 +26,6 @@ import (
2726
"sigs.k8s.io/node-feature-discovery/source"
2827
)
2928

30-
var packagePath string
31-
32-
func init() {
33-
_, thisFile, _, _ := runtime.Caller(0)
34-
packagePath = filepath.Dir(thisFile)
35-
}
36-
3729
func TestSingletonPciSource(t *testing.T) {
3830
assert.Equal(t, src.Name(), Name)
3931

@@ -232,7 +224,8 @@ func TestPciSource(t *testing.T) {
232224
// Run test cases
233225
for _, tc := range tests {
234226
t.Run(tc.name, func(t *testing.T) {
235-
hostpath.SysfsDir = hostpath.HostDir(filepath.Join(packagePath, "testdata", tc.rootfs, "sys"))
227+
mockSysfsPath := filepath.Join("..", "..", "testdata", "source", "pci", tc.rootfs, "sys")
228+
hostpath.SysfsDir = hostpath.HostDir(mockSysfsPath)
236229

237230
config := tc.config
238231
if config == nil {

testdata/README.md

Lines changed: 3 additions & 0 deletions

testdata/go.mod

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// This empty go.mod file ensures that the testdata folder is not included
2+
// in the top-level module. This prevents issues such as unsupported characters
3+
// in path names.

0 commit comments

Comments
 (0)