Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Tweaks
  • Loading branch information
BrunoQuaresma committed Sep 16, 2024
commit 4015216374bfb8986ba491dd1349d27a1aa495ca
4 changes: 2 additions & 2 deletions coderd/apidoc/docs.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions coderd/apidoc/swagger.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions coderd/workspaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -1740,8 +1740,8 @@ func (api *API) watchWorkspace(rw http.ResponseWriter, r *http.Request) {
}
}

// @Summary Return workspace timings by ID
// @ID workspace-timings-by-id
// @Summary Get workspace timings by ID
// @ID get-workspace-timings-by-id
// @Security CoderSessionToken
// @Produce json
// @Tags Workspaces
Expand Down
19 changes: 10 additions & 9 deletions coderd/workspaces_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3659,7 +3659,7 @@ func TestWorkspaceTimings(t *testing.T) {
}

// Given
tests := []struct {
testCases := []struct {
name string
provisionerTimings int
workspace workspaceWithBuild
Expand Down Expand Up @@ -3688,27 +3688,28 @@ func TestWorkspaceTimings(t *testing.T) {
},
}

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
for _, tc := range testCases {
tc := tc
t.Run(tc.name, func(t *testing.T) {
t.Parallel()

// Generate timings based on test config
generatedTimings := make([]database.ProvisionerJobTiming, tt.provisionerTimings)
if tt.provisionerTimings > 0 {
generatedTimings = makeProvisionerTimings(tt.workspace.build.JobID, tt.provisionerTimings)
generatedTimings := make([]database.ProvisionerJobTiming, tc.provisionerTimings)
if tc.provisionerTimings > 0 {
generatedTimings = makeProvisionerTimings(tc.workspace.build.JobID, tc.provisionerTimings)
}
res, err := client.WorkspaceTimings(context.Background(), tt.workspace.ID)
res, err := client.WorkspaceTimings(context.Background(), tc.workspace.ID)

// When error is expected, than an error is returned
if tt.error {
if tc.error {
require.Error(t, err)
return
}

// When success is expected, than no error is returned and the length and
// fields are correctly returned
require.NoError(t, err)
require.Len(t, res, tt.provisionerTimings)
require.Len(t, res, tc.provisionerTimings)
for i := range res.ProvisionerTimings {
timingRes := res.ProvisionerTimings[i]
require.Equal(t, generatedTimings[i].Resource, timingRes.Resource)
Expand Down
1 change: 1 addition & 0 deletions codersdk/workspaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -638,6 +638,7 @@ type ProvisionerTiming struct {

type WorkspaceTimings struct {
ProvisionerTimings []ProvisionerTiming `json:"provisioner_timings"`
// TODO: Add AgentScriptTimings when it is done https://github.com/coder/coder/issues/14630
}

func (c *Client) WorkspaceTimings(ctx context.Context, id uuid.UUID) (WorkspaceTimings, error) {
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/api/workspaces.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading