summaryrefslogtreecommitdiff
path: root/paths/paths_testutil.go
diff options
context:
space:
mode:
authorewy <ewy0@protonmail.com>2026-05-17 01:37:24 +0200
committerewy <ewy0@protonmail.com>2026-05-17 01:37:24 +0200
commitf5807d9f3a6c96e70912b61fac17120f412b5782 (patch)
treed6928795e06b1af000ffba2ae50bb6f8f7b72685 /paths/paths_testutil.go
parent7984fd9beaa7c903288142818cb328c584a139a5 (diff)
* integration tests with a pik target to run them
* add abstraction for paths to facilitate unit tests * flesh out completion (--install-completion) * do sync init before stateless modes so list knows more
Diffstat (limited to 'paths/paths_testutil.go')
-rw-r--r--paths/paths_testutil.go26
1 files changed, 26 insertions, 0 deletions
diff --git a/paths/paths_testutil.go b/paths/paths_testutil.go
new file mode 100644
index 0000000..5b8af48
--- /dev/null
+++ b/paths/paths_testutil.go
@@ -0,0 +1,26 @@
+//go:build test
+
+package paths
+
+var backups = make(map[*Path]string)
+
+func SetAll(folder string) {
+ for _, p := range Paths {
+ Set(p, folder)
+ }
+}
+
+// Set temporarily sets the paths for unit test purposes
+// remember to defer Reset
+func Set(target *Path, value string) {
+ backups[target] = target.String()
+ target.Set(value)
+}
+
+// Reset sets the path variables back to before the unit test
+func Reset() {
+ for path, oldValue := range backups {
+ path.Set(oldValue)
+ }
+ backups = make(map[*Path]string)
+}