MCPcopy Index your code
hub / github.com/jetify-com/devbox / TestComputeDevboxPathWhenRemoving

Function TestComputeDevboxPathWhenRemoving

internal/devbox/devbox_test.go:99–121  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

97}
98
99func 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
123func devboxForTesting(t *testing.T) *Devbox {
124 path := t.TempDir()

Callers

nothing calls this directly

Calls 4

KeyFunction · 0.92
devboxForTestingFunction · 0.85
computeEnvMethod · 0.80
ProjectDirHashMethod · 0.80

Tested by

no test coverage detected