summaryrefslogtreecommitdiff
path: root/paths/paths_test.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_test.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_test.go')
-rw-r--r--paths/paths_test.go43
1 files changed, 9 insertions, 34 deletions
diff --git a/paths/paths_test.go b/paths/paths_test.go
index 8ab3461..1dd9034 100644
--- a/paths/paths_test.go
+++ b/paths/paths_test.go
@@ -4,42 +4,17 @@ package paths
import (
"github.com/stretchr/testify/assert"
+ "strconv"
"testing"
)
-var bHome, bThis, bCache, bConfig string
-
-// Set temporarily sets the paths for unit test purposes
-// remember to defer Reset
-func Set(home, this, cache, config string) {
- bHome = Home
- bThis = This
- bCache = Cache
- bConfig = Config
-
- Home = home
- This = this
- Cache = cache
- Config = config
-}
-
-// Reset sets the path variables back to before the unit test
-func Reset() {
- Home = bHome
- This = bThis
- Cache = bCache
- Config = bConfig
-}
-
func TestSetAndReset(t *testing.T) {
- Set("1", "2", "3", "4")
- assert.Equal(t, Home, "1")
- assert.Equal(t, This, "2")
- assert.Equal(t, Cache, "3")
- assert.Equal(t, Config, "4")
- Reset()
- assert.NotEqual(t, Home, "1")
- assert.NotEqual(t, This, "2")
- assert.NotEqual(t, Cache, "3")
- assert.NotEqual(t, Config, "4")
+ for i, pt := range Paths {
+ old := pt.String()
+ val := strconv.Itoa(i)
+ Set(pt, val)
+ assert.Equal(t, pt.String(), val)
+ Reset()
+ assert.Equal(t, pt.String(), old)
+ }
}