mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
fix: log after test exit in TestAgent/StartupScript (#1726)
```
$ go test ./agent/ -v -run TestAgent/StartupScript -count 1
=== RUN TestAgent
=== PAUSE TestAgent
=== CONT TestAgent
=== RUN TestAgent/StartupScript
=== PAUSE TestAgent/StartupScript
=== CONT TestAgent/StartupScript
t.go:56: 2022-05-24 20:22:39.648 [INFO] <agent.go:112> connected
--- PASS: TestAgent (0.00s)
--- PASS: TestAgent/StartupScript (0.17s)
PASS
panic: Log in goroutine after TestAgent/StartupScript has completed: 2022-05-24 20:22:39.651 [WARN] <agent.go:130> agent script failed ...
"error": run:
github.com/coder/coder/agent.(*agent).runStartupScript
/home/colin/Projects/coder/coder/agent/agent.go:183
- signal: killed
```
This commit is contained in:
+4
-1
@@ -172,8 +172,9 @@ func TestAgent(t *testing.T) {
|
||||
tempPath := filepath.Join(os.TempDir(), "content.txt")
|
||||
content := "somethingnice"
|
||||
setupAgent(t, agent.Metadata{
|
||||
StartupScript: "echo " + content + " > " + tempPath,
|
||||
StartupScript: fmt.Sprintf("echo %s > %s", content, tempPath),
|
||||
}, 0)
|
||||
|
||||
var gotContent string
|
||||
require.Eventually(t, func() bool {
|
||||
content, err := os.ReadFile(tempPath)
|
||||
@@ -202,6 +203,7 @@ func TestAgent(t *testing.T) {
|
||||
// it seems like it could be either.
|
||||
t.Skip("ConPTY appears to be inconsistent on Windows.")
|
||||
}
|
||||
|
||||
conn := setupAgent(t, agent.Metadata{}, 0)
|
||||
id := uuid.NewString()
|
||||
netConn, err := conn.ReconnectingPTY(id, 100, 100)
|
||||
@@ -228,6 +230,7 @@ func TestAgent(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
matchEchoCommand := func(line string) bool {
|
||||
return strings.Contains(line, "echo test")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user