MCPcopy Create free account
hub / github.com/algolia/cli / TestCheckForUpdate

Function TestCheckForUpdate

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

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 7

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

Tested by

no test coverage detected