Skip to content

Commit

Permalink
Move testdata to root
Browse files Browse the repository at this point in the history
Go mod automatically ignores the /testdata directory.
This change ensures that the rootfs for source/pci tests are not
included in the module definition.

Signed-off-by: Evan Lezar <[email protected]>
  • Loading branch information
elezar committed Oct 23, 2024
1 parent cce709f commit 56bbad8
Show file tree
Hide file tree
Showing 263 changed files with 2 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

0 comments on commit 56bbad8

Please sign in to comment.