agent: TestOmo and TestJcodeHome no longer fail where omo or jcode is installed (#1646, ggbdpq)
Both tests check that the agent is not detected before its folder exists. Detected also looks for the agent's command on PATH, so an omo or jcode installed on the host made the tests fail. Both tests now run with an empty temp dir as PATH. The TestOmo line is the reporter's. To find every test with this problem, the whole agent package was run with a fake executable on PATH for each agent id and Bin (145 names): - TestOmo and TestJcodeHome failed. - TestInstallWithoutNodeStopsWhenTheDownloadFails also failed, but only because the fake curl stood in for the real one. That is not an agent detection. With this change, both tests pass with the fakes on PATH. go test -tags nogui ./internal/agent/ is green, and gofmt -l and go vet are clean on darwin, linux and windows.
This commit is contained in:
@@ -284,6 +284,7 @@ X-Team = "mine"
|
||||
// the file while jcode still starts on it is said.
|
||||
func TestJcodeHome(t *testing.T) {
|
||||
home, _ := jcodeHome(t, "")
|
||||
t.Setenv("PATH", t.TempDir()) // no jcode on PATH: only its folder tells (#1646)
|
||||
dir := filepath.Join(home, "elsewhere")
|
||||
t.Setenv("JCODE_HOME", dir)
|
||||
a := jcode(home)
|
||||
|
||||
@@ -18,6 +18,7 @@ import (
|
||||
// Pi's ~/.pi is left alone; its own model takes magpie out again.
|
||||
func TestOmo(t *testing.T) {
|
||||
home := syncHome(t)
|
||||
t.Setenv("PATH", t.TempDir()) // no omo on PATH: only its folder tells (#1646)
|
||||
var a *Agent
|
||||
for _, x := range All() {
|
||||
if x.ID == "omo" {
|
||||
|
||||
Reference in New Issue
Block a user