(t *testing.T)
| 97 | } |
| 98 | |
| 99 | func TestComputeDevboxPathWhenRemoving(t *testing.T) { |
| 100 | devbox := devboxForTesting(t) |
| 101 | devbox.nix = &testNix{"/tmp/my/path"} |
| 102 | ctx := t.Context() |
| 103 | env, err := devbox.computeEnv(ctx, false /*use cache*/, devopt.EnvOptions{}) |
| 104 | require.NoError(t, err, "computeEnv should not fail") |
| 105 | path := env["PATH"] |
| 106 | assert.NotEmpty(t, path, "path should not be nil") |
| 107 | assert.Contains(t, path, "/tmp/my/path", "path should contain /tmp/my/path") |
| 108 | |
| 109 | t.Setenv("PATH", path) |
| 110 | t.Setenv(envpath.InitPathEnv, env[envpath.InitPathEnv]) |
| 111 | t.Setenv(envpath.PathStackEnv, env[envpath.PathStackEnv]) |
| 112 | t.Setenv(envpath.Key(devbox.ProjectDirHash()), env[envpath.Key(devbox.ProjectDirHash())]) |
| 113 | |
| 114 | devbox.nix.(*testNix).path = "" |
| 115 | env, err = devbox.computeEnv(ctx, false /*use cache*/, devopt.EnvOptions{}) |
| 116 | require.NoError(t, err, "computeEnv should not fail") |
| 117 | path2 := env["PATH"] |
| 118 | assert.NotContains(t, path2, "/tmp/my/path", "path should not contain /tmp/my/path") |
| 119 | |
| 120 | assert.NotEqual(t, path, path2, "path should not be the same") |
| 121 | } |
| 122 | |
| 123 | func devboxForTesting(t *testing.T) *Devbox { |
| 124 | path := t.TempDir() |
nothing calls this directly
no test coverage detected