diff options
| author | Ophestra <cat@gensokyo.uk> | 2025-03-15 00:27:44 +0900 |
|---|---|---|
| committer | Ophestra <cat@gensokyo.uk> | 2025-03-15 00:27:44 +0900 |
| commit | f443d315ad60d761c06135569abb0adb183ac8c1 (patch) | |
| tree | e22b866dc239cd888ef7f3d2ffadaf6a14bd51aa /helper/direct_test.go | |
| parent | 9e18d1de77b2c9bb24a51c2e99b060c6d06818ee (diff) | |
helper: clean up interface
The helper interface was messy due to odd context acquisition order. That has changed, so this cleans it up.
Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'helper/direct_test.go')
| -rw-r--r-- | helper/direct_test.go | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/helper/direct_test.go b/helper/direct_test.go index e7bda797..7af0e3a6 100644 --- a/helper/direct_test.go +++ b/helper/direct_test.go @@ -4,6 +4,7 @@ import ( "context" "errors" "os" + "os/exec" "testing" "git.gensokyo.uk/security/fortify/helper" @@ -11,16 +12,16 @@ import ( func TestDirect(t *testing.T) { t.Run("start non-existent helper path", func(t *testing.T) { - h := helper.New(context.Background(), argsWt, "/nonexistent", argF) + h := helper.NewDirect(context.Background(), argsWt, "/nonexistent", argF, nil, false) - if err := h.Start(false); !errors.Is(err, os.ErrNotExist) { + 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.New(context.TODO(), argsWt, "fortify", argF); got == nil { + if got := helper.NewDirect(context.TODO(), argsWt, "fortify", argF, nil, false); got == nil { t.Errorf("New(%q, %q) got nil", argsWt, "fortify") return @@ -28,6 +29,8 @@ func TestDirect(t *testing.T) { }) t.Run("implementation compliance", func(t *testing.T) { - testHelper(t, func(ctx context.Context) helper.Helper { return helper.New(ctx, argsWt, "crash-test-dummy", argF) }) + testHelper(t, func(ctx context.Context, cmdF func(cmd *exec.Cmd), stat bool) helper.Helper { + return helper.NewDirect(ctx, argsWt, "crash-test-dummy", argF, cmdF, stat) + }) }) } |
