mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
feat: add exit code and status to workspace agent scripts (#24505)
For scripts that have not finished or in dry run cases these will be omitted.
This commit is contained in:
@@ -5027,7 +5027,7 @@ func TestWorkspaceTimings(t *testing.T) {
|
||||
scripts := dbgen.WorkspaceAgentScripts(t, db, 3, database.WorkspaceAgentScript{
|
||||
WorkspaceAgentID: agent.ID,
|
||||
})
|
||||
dbgen.WorkspaceAgentScriptTimings(t, db, scripts)
|
||||
timings := dbgen.WorkspaceAgentScriptTimings(t, db, scripts)
|
||||
|
||||
// When: fetching the timings
|
||||
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitLong)
|
||||
@@ -5038,6 +5038,19 @@ func TestWorkspaceTimings(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
require.Len(t, res.ProvisionerTimings, 5)
|
||||
require.Len(t, res.AgentScriptTimings, 3)
|
||||
|
||||
// The same timings should be on the workspace response.
|
||||
workspace, err := client.Workspace(ctx, ws.ID)
|
||||
require.NoError(t, err)
|
||||
require.Len(t, workspace.LatestBuild.Resources[0].Agents[0].Scripts, 3)
|
||||
for _, script := range workspace.LatestBuild.Resources[0].Agents[0].Scripts {
|
||||
timing, found := slice.Find(timings, func(timing database.WorkspaceAgentScriptTiming) bool {
|
||||
return timing.ScriptID == script.ID
|
||||
})
|
||||
require.True(t, found)
|
||||
require.Equal(t, *script.ExitCode, timing.ExitCode)
|
||||
require.Equal(t, *script.Status, codersdk.WorkspaceAgentScriptStatus(timing.Status))
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("NonExistentWorkspace", func(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user