Skip to content

Commit

Permalink
Merge pull request #1928 from elezar/cherry-pick-testdata-changes
Browse files Browse the repository at this point in the history
Cherry pick testdata changes
  • Loading branch information
k8s-ci-robot authored Oct 25, 2024
2 parents cce709f + 6c5604e commit 514da84
Show file tree
Hide file tree
Showing 265 changed files with 8 additions and 9 deletions.
11 changes: 2 additions & 9 deletions source/pci/pci_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ package pci

import (
"path/filepath"
"runtime"
"testing"

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

var packagePath string

func init() {
_, thisFile, _, _ := runtime.Caller(0)
packagePath = filepath.Dir(thisFile)
}

func TestSingletonPciSource(t *testing.T) {
assert.Equal(t, src.Name(), Name)

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

config := tc.config
if config == nil {
Expand Down
3 changes: 3 additions & 0 deletions testdata/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Some of the test data in this folder contains colon characters which causes "go get" commands to fail with "invalid char ':'".
The empty go.mod file is a workaround to prevent this error. This effectively makes this folder its own go module, so it will be
ignored when "go get" is executed.
3 changes: 3 additions & 0 deletions testdata/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// This empty go.mod file ensures that the testdata folder is not included
// in the top-level module. This prevents issues such as unsupported characters
// in path names.

0 comments on commit 514da84

Please sign in to comment.