test(commands): add coverage for AddPath init flag
This commit is contained in:
parent
906cf9a4b0
commit
037409a460
1 changed files with 25 additions and 0 deletions
|
@ -1,11 +1,13 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
cli "v/cli"
|
cli "v/cli"
|
||||||
|
logger "v/logger"
|
||||||
python "v/python"
|
python "v/python"
|
||||||
state "v/state"
|
state "v/state"
|
||||||
testutils "v/testutils"
|
testutils "v/testutils"
|
||||||
|
@ -79,3 +81,26 @@ func TestInitializeCreatesAllPythonShims(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestInitializeWithAddPathPrintsExportPATH(t *testing.T) {
|
||||||
|
defer testutils.SetupAndCleanupEnvironment(t)()
|
||||||
|
|
||||||
|
var buf bytes.Buffer
|
||||||
|
|
||||||
|
logger.InfoLogger.SetOutput(&buf)
|
||||||
|
|
||||||
|
defer func() {
|
||||||
|
logger.InfoLogger.SetOutput(os.Stdout)
|
||||||
|
}()
|
||||||
|
|
||||||
|
err := Initialize([]string{}, cli.Flags{AddPath: true}, state.State{})
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("Unexpected error: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
expected := "export PATH=" + state.GetStatePath("shims") + ":$PATH\n"
|
||||||
|
if buf.String() != expected {
|
||||||
|
t.Errorf("Expected PATH export, got %s", buf.String())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue