aboutsummaryrefslogtreecommitdiffhomepage
path: root/helper/cmd_test.go
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2025-03-15 02:10:22 +0900
committerOphestra <cat@gensokyo.uk>2025-03-15 02:10:22 +0900
commit0f1f0e43643d302494c0dac8bbc3eda7813f06bb (patch)
tree4730fd645c2b958a48495ee4a5644e538bf0ba8b /helper/cmd_test.go
parentf9bf20a3c75d01cf597477231f9bbb61f15cd4fd (diff)
helper: combine helper ipc setup
The two-step args call is no longer necessary since stat is passed on initialisation. Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'helper/cmd_test.go')
-rw-r--r--helper/cmd_test.go36
1 files changed, 36 insertions, 0 deletions
diff --git a/helper/cmd_test.go b/helper/cmd_test.go
new file mode 100644
index 00000000..6431edec
--- /dev/null
+++ b/helper/cmd_test.go
@@ -0,0 +1,36 @@
+package helper_test
+
+import (
+ "context"
+ "errors"
+ "os"
+ "os/exec"
+ "testing"
+
+ "git.gensokyo.uk/security/fortify/helper"
+)
+
+func TestDirect(t *testing.T) {
+ t.Run("start non-existent helper path", func(t *testing.T) {
+ h := helper.NewDirect(context.Background(), "/nonexistent", argsWt, false, argF, nil)
+
+ if err := h.Start(); !errors.Is(err, os.ErrNotExist) {
+ t.Errorf("Start: error = %v, wantErr %v",
+ err, os.ErrNotExist)
+ }
+ })
+
+ t.Run("valid new helper nil check", func(t *testing.T) {
+ if got := helper.NewDirect(context.TODO(), "fortify", argsWt, false, argF, nil); got == nil {
+ t.Errorf("New(%q, %q) got nil",
+ argsWt, "fortify")
+ return
+ }
+ })
+
+ t.Run("implementation compliance", func(t *testing.T) {
+ testHelper(t, func(ctx context.Context, cmdF func(cmd *exec.Cmd), stat bool) helper.Helper {
+ return helper.NewDirect(ctx, "crash-test-dummy", argsWt, stat, argF, cmdF)
+ })
+ })
+}