Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9753283

Browse files
committed
update test to depend on path expansion
1 parent 6ec33aa commit 9753283

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

agent/agent_test.go

+10-6
Original file line numberDiff line numberDiff line change
@@ -1998,8 +1998,8 @@ func TestAgent_ReconnectingPTYContainer(t *testing.T) {
19981998
// You can run it manually as follows:
19991999
//
20002000
// CODER_TEST_USE_DOCKER=1 go test -count=1 ./agent -run TestAgent_DevcontainerAutostart
2001+
// nolint: paralleltest // This test sets an environment variable.
20012002
func TestAgent_DevcontainerAutostart(t *testing.T) {
2002-
t.Parallel()
20032003
if os.Getenv("CODER_TEST_USE_DOCKER") != "1" {
20042004
t.Skip("Set CODER_TEST_USE_DOCKER=1 to run this test")
20052005
}
@@ -2012,9 +2012,12 @@ func TestAgent_DevcontainerAutostart(t *testing.T) {
20122012

20132013
// Prepare temporary devcontainer for test (mywork).
20142014
devcontainerID := uuid.New()
2015-
tempWorkspaceFolder := t.TempDir()
2016-
tempWorkspaceFolder = filepath.Join(tempWorkspaceFolder, "mywork")
2015+
tmpdir := t.TempDir()
2016+
t.Setenv("HOME", tmpdir)
2017+
tempWorkspaceFolder := filepath.Join(tmpdir, "mywork")
2018+
unexpandedWorkspaceFolder := filepath.Join("~", "mywork")
20172019
t.Logf("Workspace folder: %s", tempWorkspaceFolder)
2020+
t.Logf("Unexpanded workspace folder: %s", unexpandedWorkspaceFolder)
20182021
devcontainerPath := filepath.Join(tempWorkspaceFolder, ".devcontainer")
20192022
err = os.MkdirAll(devcontainerPath, 0o755)
20202023
require.NoError(t, err, "create devcontainer directory")
@@ -2031,9 +2034,10 @@ func TestAgent_DevcontainerAutostart(t *testing.T) {
20312034
// is expected to be prepared by the provisioner normally.
20322035
Devcontainers: []codersdk.WorkspaceAgentDevcontainer{
20332036
{
2034-
ID: devcontainerID,
2035-
Name: "test",
2036-
WorkspaceFolder: tempWorkspaceFolder,
2037+
ID: devcontainerID,
2038+
Name: "test",
2039+
// Use an unexpanded path to test the expansion.
2040+
WorkspaceFolder: unexpandedWorkspaceFolder,
20372041
},
20382042
},
20392043
Scripts: []codersdk.WorkspaceAgentScript{

0 commit comments

Comments
 (0)