Merge pull request 'fix: CodeRabbit review findings for Env/Path' (#22) from dev into main
Some checks failed
CI / test (push) Failing after 2s

This commit is contained in:
Virgil 2026-03-22 10:13:15 +00:00
commit fb04b28419
3 changed files with 13 additions and 4 deletions

View file

@ -34,6 +34,10 @@ func TestEnv_PS(t *testing.T) {
} }
func TestEnv_DIR_HOME(t *testing.T) { func TestEnv_DIR_HOME(t *testing.T) {
if ch := os.Getenv("CORE_HOME"); ch != "" {
assert.Equal(t, ch, core.Env("DIR_HOME"))
return
}
home, err := os.UserHomeDir() home, err := os.UserHomeDir()
require.NoError(t, err) require.NoError(t, err)
assert.Equal(t, home, core.Env("DIR_HOME")) assert.Equal(t, home, core.Env("DIR_HOME"))

View file

@ -1,8 +1,8 @@
// SPDX-License-Identifier: EUPL-1.2 // SPDX-License-Identifier: EUPL-1.2
// OS-aware filesystem path operations for the Core framework. // OS-aware filesystem path operations for the Core framework.
// Zero filepath import — uses Env("DS") for the separator and // Uses Env("DS") for the separator and Core string primitives
// Core string primitives for all path manipulation. // for path manipulation. filepath imported only for PathGlob.
// //
// Path anchors relative segments to DIR_HOME: // Path anchors relative segments to DIR_HOME:
// //
@ -29,6 +29,9 @@ import "path/filepath"
func Path(segments ...string) string { func Path(segments ...string) string {
ds := Env("DS") ds := Env("DS")
home := Env("DIR_HOME") home := Env("DIR_HOME")
if home == "" {
home = "."
}
if len(segments) == 0 { if len(segments) == 0 {
return home return home
} }

View file

@ -19,7 +19,8 @@ func TestPath_Relative(t *testing.T) {
} }
func TestPath_Absolute(t *testing.T) { func TestPath_Absolute(t *testing.T) {
assert.Equal(t, "/tmp/workspace", core.Path("/tmp", "workspace")) ds := core.Env("DS")
assert.Equal(t, "/tmp"+ds+"workspace", core.Path("/tmp", "workspace"))
} }
func TestPath_Empty(t *testing.T) { func TestPath_Empty(t *testing.T) {
@ -35,7 +36,8 @@ func TestPath_Cleans(t *testing.T) {
} }
func TestPath_CleanDoubleSlash(t *testing.T) { func TestPath_CleanDoubleSlash(t *testing.T) {
assert.Equal(t, "/tmp/file", core.Path("/tmp//file")) ds := core.Env("DS")
assert.Equal(t, ds+"tmp"+ds+"file", core.Path("/tmp//file"))
} }
func TestPathBase(t *testing.T) { func TestPathBase(t *testing.T) {