From a280f499d27c4e187af61a3c688e76294b387ec6 Mon Sep 17 00:00:00 2001 From: jabdr Date: Sun, 25 Aug 2024 23:43:55 +0200 Subject: [PATCH] fix: broken TestInspectFile on windows (#1133) --- internal/operators/inspect_file_test.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/internal/operators/inspect_file_test.go b/internal/operators/inspect_file_test.go index 73458758f..b4c1ed122 100644 --- a/internal/operators/inspect_file_test.go +++ b/internal/operators/inspect_file_test.go @@ -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, }, { @@ -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) } })