Skip to content

Commit

Permalink
fix: resolve release info bug
Browse files Browse the repository at this point in the history
  • Loading branch information
ravisuhag committed Nov 2, 2024
1 parent f246388 commit c238b6e
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 21 deletions.
2 changes: 1 addition & 1 deletion version/release.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func ReleaseInfo(releaseURL string) (*Info, error) {
}
}()
if resp.StatusCode != http.StatusOK {
return nil, errors.Wrapf(err, "failed to reach releaseURL: %s, status code: %d", releaseURL, resp.StatusCode)
return nil, fmt.Errorf("failed to reach releaseURL: %s, status code: %d", releaseURL, resp.StatusCode)
}

body, err := io.ReadAll(resp.Body)
Expand Down
20 changes: 0 additions & 20 deletions version/release_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,26 +77,6 @@ func TestIsCurrentLatest(t *testing.T) {
}
}

func TestUpdateNotice(t *testing.T) {
// Mock a successful GitHub API response with a newer version
mockResponse := `{
"tag_name": "v2.0.0",
"tarball_url": "https://example.com/tarball/v2.0.0"
}`
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusOK)
w.Write([]byte(mockResponse))
}))
defer server.Close()

notice := UpdateNotice("1.0.0", server.URL)
assert.Equal(t, "A new release (v2.0.0) is available, consider updating the client.", notice)

// Test with the current version being the latest
notice = UpdateNotice("2.0.0", server.URL)
assert.Equal(t, "", notice)
}

func TestUpdateNotice_ErrorHandling(t *testing.T) {
// Mock a server that returns an error
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
Expand Down

0 comments on commit c238b6e

Please sign in to comment.