MCPcopy
hub / github.com/cli/cli / TestCheckForUpdate

Function TestCheckForUpdate

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

Source from the content-addressed store, hash-verified

17)
18
19func TestCheckForUpdate(t *testing.T) {
20 scenarios := []struct {
21 Name string
22 CurrentVersion string
23 LatestVersion string
24 LatestURL string
25 ExpectsResult bool
26 }{
27 {
28 Name: "latest is newer",
29 CurrentVersion: "v0.0.1",
30 LatestVersion: "v1.0.0",
31 LatestURL: "https://www.spacejam.com/archive/spacejam/movie/jam.htm",
32 ExpectsResult: true,
33 },
34 {
35 Name: "current is prerelease",
36 CurrentVersion: "v1.0.0-pre.1",
37 LatestVersion: "v1.0.0",
38 LatestURL: "https://www.spacejam.com/archive/spacejam/movie/jam.htm",
39 ExpectsResult: true,
40 },
41 {
42 Name: "current is built from source",
43 CurrentVersion: "v1.2.3-123-gdeadbeef",
44 LatestVersion: "v1.2.3",
45 LatestURL: "https://www.spacejam.com/archive/spacejam/movie/jam.htm",
46 ExpectsResult: false,
47 },
48 {
49 Name: "current is built from source after a prerelease",
50 CurrentVersion: "v1.2.3-rc.1-123-gdeadbeef",
51 LatestVersion: "v1.2.3",
52 LatestURL: "https://www.spacejam.com/archive/spacejam/movie/jam.htm",
53 ExpectsResult: true,
54 },
55 {
56 Name: "latest is newer than version build from source",
57 CurrentVersion: "v1.2.3-123-gdeadbeef",
58 LatestVersion: "v1.2.4",
59 LatestURL: "https://www.spacejam.com/archive/spacejam/movie/jam.htm",
60 ExpectsResult: true,
61 },
62 {
63 Name: "latest is current",
64 CurrentVersion: "v1.0.0",
65 LatestVersion: "v1.0.0",
66 LatestURL: "https://www.spacejam.com/archive/spacejam/movie/jam.htm",
67 ExpectsResult: false,
68 },
69 {
70 Name: "latest is older",
71 CurrentVersion: "v0.10.0-pre.1",
72 LatestVersion: "v0.9.0",
73 LatestURL: "https://www.spacejam.com/archive/spacejam/movie/jam.htm",
74 ExpectsResult: false,
75 },
76 }

Callers

nothing calls this directly

Calls 8

RegisterMethod · 0.95
ReplaceTripperFunction · 0.92
RESTFunction · 0.92
StringResponseFunction · 0.92
CheckForUpdateFunction · 0.85
tempFilePathFunction · 0.85
RunMethod · 0.65
ErrorfMethod · 0.65

Tested by

no test coverage detected