summaryrefslogtreecommitdiff
path: root/tests/e2e/test_helpers.go
diff options
context:
space:
mode:
authorJames O'Doherty <james@theodohertyfamily.com>2026-06-04 22:57:35 -0400
committerJames O'Doherty <james@theodohertyfamily.com>2026-06-04 22:57:35 -0400
commit04dca5dada8c2d971ff3b54eeedc5ab6e53a29ac (patch)
treea9890073a0eb21bc7db3aef2fcbe66cdc2fc9ceb /tests/e2e/test_helpers.go
parent66b782e261f1cd928ad6a8482788a65fb484db45 (diff)
refactor: decouple namespace operations and improve test coverage
- Introduce `namespace.Ops` interface to decouple `Manager` from system-level namespace operations, enabling easier unit testing via mocks. - Add unit tests for `internal/paths` to verify path resolution logic across different environment configurations. - Implement `EnsureBinary` helper in E2E tests to gracefully skip tests when `WG_WRAP_BIN` is not set, allowing `go test ./...` to pass in non-build environments. - Apply project-wide formatting and fix linting issues.
Diffstat (limited to 'tests/e2e/test_helpers.go')
-rw-r--r--tests/e2e/test_helpers.go11
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/e2e/test_helpers.go b/tests/e2e/test_helpers.go
index 6d65011..93e851c 100644
--- a/tests/e2e/test_helpers.go
+++ b/tests/e2e/test_helpers.go
@@ -4,6 +4,7 @@ import (
"fmt"
"os"
"strings"
+ "testing"
)
// GetBinaryPath resolves the path to the wg-wrap binary.
@@ -21,6 +22,16 @@ func GetBinaryPath() (string, error) {
return path, nil
}
+// EnsureBinary returns the path to the wg-wrap binary or skips the test if it's not available.
+func EnsureBinary(t *testing.T) string {
+ t.Helper()
+ bin, err := GetBinaryPath()
+ if err != nil {
+ t.Skipf("skipping test: %v", err)
+ }
+ return bin
+}
+
// SetEnvOverrides returns a new slice of environment variables with the provided overrides applied.
// It ensures that overriding an existing variable replaces it rather than appending it.
func SetEnvOverrides(overrides map[string]string) []string {