Skip to content

Commit

Permalink
fix: broken TestInspectFile on windows (#1133)
Browse files Browse the repository at this point in the history
  • Loading branch information
jabdr authored Aug 25, 2024
1 parent ff6cd1e commit a280f49
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions internal/operators/inspect_file_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,24 @@ package operators
import (
_ "fmt"
"path/filepath"
"runtime"
"testing"

"github.com/corazawaf/coraza/v3/experimental/plugins/plugintypes"
)

func TestInspectFile(t *testing.T) {
existCommand := "/bin/echo"
if runtime.GOOS == "windows" {
existCommand = "C:\\Windows\\system32\\tasklist.exe"
}

tests := []struct {
path string
exists bool
}{
{
// TODO(anuraaga): Don't have this rely on OS details.
path: "/bin/echo",
path: existCommand,
exists: true,
},
{
Expand All @@ -37,7 +42,7 @@ func TestInspectFile(t *testing.T) {
if err != nil {
t.Error("cannot init inspectfile operator")
}
if want, have := tt.exists, ipf.Evaluate(nil, ""); want != have {
if want, have := tt.exists, ipf.Evaluate(nil, "/?"); want != have {
t.Errorf("inspectfile path %s: want %v, have %v", tt.path, want, have)
}
})
Expand Down

0 comments on commit a280f49

Please sign in to comment.