(t *testing.T)
| 103 | } |
| 104 | |
| 105 | func TestCheckForUpdate_RateLimited(t *testing.T) { |
| 106 | srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { |
| 107 | w.WriteHeader(http.StatusForbidden) |
| 108 | })) |
| 109 | defer srv.Close() |
| 110 | |
| 111 | result, err := CheckForUpdate("0.5.0", Options{ReleasesURL: srv.URL}) |
| 112 | if err != nil { |
| 113 | t.Fatalf("expected no error for rate-limited response, got: %v", err) |
| 114 | } |
| 115 | if result.UpdateAvailable { |
| 116 | t.Error("expected no update when rate limited") |
| 117 | } |
| 118 | if result.CurrentVersion != "0.5.0" { |
| 119 | t.Errorf("expected current version 0.5.0, got %s", result.CurrentVersion) |
| 120 | } |
| 121 | } |
| 122 | |
| 123 | func TestCheckForUpdate_APIError(t *testing.T) { |
| 124 | srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { |
nothing calls this directly
no test coverage detected