Skip to content

Commit f93e987

Browse files
committed
make TestReinitializeAgent work on Windows
1 parent 818d4d0 commit f93e987

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

enterprise/coderd/workspaceagents_test.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"net/http"
88
"os"
99
"regexp"
10+
"runtime"
1011
"testing"
1112
"time"
1213

@@ -89,6 +90,13 @@ func TestReinitializeAgent(t *testing.T) {
8990
t.Skip("dbmem cannot currently claim a workspace")
9091
}
9192

93+
var startupScript string
94+
if runtime.GOOS == "windows" {
95+
startupScript = fmt.Sprintf("cmd.exe /c set >> \"%s\" && echo --- >> \"%s\"", tempAgentLog.Name(), tempAgentLog.Name())
96+
} else {
97+
startupScript = fmt.Sprintf("printenv >> %s; echo '---\n' >> %s", tempAgentLog.Name(), tempAgentLog.Name())
98+
}
99+
92100
db, ps := dbtestutil.NewDB(t)
93101
// GIVEN a live enterprise API with the prebuilds feature enabled
94102
client, user := coderdenttest.New(t, &coderdenttest.Options{
@@ -155,7 +163,7 @@ func TestReinitializeAgent(t *testing.T) {
155163
Scripts: []*proto.Script{
156164
{
157165
RunOnStart: true,
158-
Script: fmt.Sprintf("printenv >> %s; echo '---\n' >> %s", tempAgentLog.Name(), tempAgentLog.Name()), // Make reinitialization take long enough to assert that it happened
166+
Script: startupScript,
159167
},
160168
},
161169
Auth: &proto.Agent_Token{

0 commit comments

Comments
 (0)