src-cli: Fix version output (#40928)

This commit is contained in:
Eric Fritz 2022-08-26 11:37:12 -05:00 committed by GitHub
parent 27f21112a9
commit b09161cef1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 2 deletions

View File

@ -173,7 +173,9 @@ func (h *srcCliVersionHandler) handleDownload(w http.ResponseWriter, r *http.Req
}
func (h *srcCliVersionHandler) handleVersion(w http.ResponseWriter) {
writeJSON(w, h.Version())
writeJSON(w, struct {
Version string `json:"version"`
}{Version: h.Version()})
}
func isExpectedRelease(filename string) bool {

View File

@ -71,7 +71,7 @@ func TestSrcCliVersionHandler_ServeHTTP(t *testing.T) {
handler.ServeHTTP(rec, req)
assert.Equal(t, http.StatusOK, rec.Code)
assert.Equal(t, "\"3.42.1\"\n", rec.Body.String())
assert.Equal(t, `{"version":"3.42.1"}`+"\n", rec.Body.String())
})
t.Run("download", func(t *testing.T) {