MCPcopy Create free account
hub / github.com/MiniCodeMonkey/chief / TestCheckForUpdate_UpdateAvailable

Function TestCheckForUpdate_UpdateAvailable

internal/update/update_test.go:16–39  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

14)
15
16func TestCheckForUpdate_UpdateAvailable(t *testing.T) {
17 release := Release{
18 TagName: "v0.5.1",
19 Assets: []Asset{{Name: "chief-linux-amd64", BrowserDownloadURL: "http://example.com/chief"}},
20 }
21 srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
22 json.NewEncoder(w).Encode(release)
23 }))
24 defer srv.Close()
25
26 result, err := CheckForUpdate("0.5.0", Options{ReleasesURL: srv.URL})
27 if err != nil {
28 t.Fatalf("unexpected error: %v", err)
29 }
30 if !result.UpdateAvailable {
31 t.Error("expected update to be available")
32 }
33 if result.LatestVersion != "0.5.1" {
34 t.Errorf("expected latest version 0.5.1, got %s", result.LatestVersion)
35 }
36 if result.CurrentVersion != "0.5.0" {
37 t.Errorf("expected current version 0.5.0, got %s", result.CurrentVersion)
38 }
39}
40
41func TestCheckForUpdate_AlreadyLatest(t *testing.T) {
42 release := Release{TagName: "v0.5.0"}

Callers

nothing calls this directly

Calls 1

CheckForUpdateFunction · 0.85

Tested by

no test coverage detected