-
Notifications
You must be signed in to change notification settings - Fork 874
chore: Add test helpers to improve coverage #166
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
7f2a99f
7c46342
9e04a0e
9cd8b43
be3e6ac
6e4ca5a
ab4dcb1
57efae2
9fa815c
0fb2a5a
c50cee0
e202b2d
ca31d90
673c59d
aad577f
6c39920
a4d17d0
a8a0531
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -87,14 +87,16 @@ func (api *api) workspaceHistoryLogsByName(rw http.ResponseWriter, r *http.Reque | |
}) | ||
if errors.Is(err, sql.ErrNoRows) { | ||
err = nil | ||
logs = []database.WorkspaceHistoryLog{} | ||
} | ||
if err != nil { | ||
httpapi.Write(rw, http.StatusInternalServerError, httpapi.Response{ | ||
Message: fmt.Sprintf("get workspace history: %s", err), | ||
}) | ||
return | ||
} | ||
if logs == nil { | ||
logs = []database.WorkspaceHistoryLog{} | ||
} | ||
Comment on lines
+97
to
+99
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder if this is the same issue I saw with projects? Sometimes, I'd get I didn't get a chance to dive deeper yet (I'll look at it next week) - but wondering if its the same issue here? And maybe a bug with our query or There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yup, it is! Not an issue with our There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Cool, good to know! I didn't realize that there could be a case where those functions could return |
||
render.Status(r, http.StatusOK) | ||
render.JSON(rw, r, logs) | ||
return | ||
|
@@ -113,12 +115,8 @@ func (api *api) workspaceHistoryLogsByName(rw http.ResponseWriter, r *http.Reque | |
select { | ||
case bufferedLogs <- log: | ||
default: | ||
// This is a case that shouldn't happen, but totally could. | ||
// There's no way to stream data from the database, so we'll | ||
// need to maintain some level of internal buffer. | ||
// | ||
// If this overflows users could miss logs when streaming. | ||
// We warn to make sure we know when it happens! | ||
// If this overflows users could miss logs streaming. This can happen | ||
// if a database request takes a long amount of time, and we get a lot of logs. | ||
api.Logger.Warn(r.Context(), "workspace history log overflowing channel") | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess this is just to get the JSON to return an empty array instead of
nil
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exactly!