MCPcopy
hub / github.com/cli/cli / TestCheckForExtensionUpdate

Function TestCheckForExtensionUpdate

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

Source from the content-addressed store, hash-verified

123}
124
125func TestCheckForExtensionUpdate(t *testing.T) {
126 now := time.Date(2024, 12, 17, 12, 0, 0, 0, time.UTC)
127 previousTooSoon := now.Add(-23 * time.Hour).Add(-59 * time.Minute).Add(-59 * time.Second)
128 previousOldEnough := now.Add(-24 * time.Hour)
129
130 tests := []struct {
131 name string
132 extCurrentVersion string
133 extLatestVersion string
134 extKind extension.ExtensionKind
135 extURL string
136 previousStateEntry *StateEntry
137 expectedStateEntry *StateEntry
138 expectedReleaseInfo *ReleaseInfo
139 wantErr bool
140 }{
141 {
142 name: "return latest release given git extension is out of date and no state entry",
143 extCurrentVersion: "v0.1.0",
144 extLatestVersion: "v1.0.0",
145 extKind: extension.GitKind,
146 extURL: "http://example.com",
147 expectedStateEntry: &StateEntry{
148 CheckedForUpdateAt: now,
149 LatestRelease: ReleaseInfo{
150 Version: "v1.0.0",
151 URL: "http://example.com",
152 },
153 },
154 expectedReleaseInfo: &ReleaseInfo{
155 Version: "v1.0.0",
156 URL: "http://example.com",
157 },
158 },
159 {
160 name: "return latest release given git extension is out of date and state entry is old enough",
161 extCurrentVersion: "v0.1.0",
162 extLatestVersion: "v1.0.0",
163 extKind: extension.GitKind,
164 extURL: "http://example.com",
165 previousStateEntry: &StateEntry{
166 CheckedForUpdateAt: previousOldEnough,
167 LatestRelease: ReleaseInfo{
168 Version: "v0.1.0",
169 URL: "http://example.com",
170 },
171 },
172 expectedStateEntry: &StateEntry{
173 CheckedForUpdateAt: now,
174 LatestRelease: ReleaseInfo{
175 Version: "v1.0.0",
176 URL: "http://example.com",
177 },
178 },
179 expectedReleaseInfo: &ReleaseInfo{
180 Version: "v1.0.0",
181 URL: "http://example.com",
182 },

Callers

nothing calls this directly

Calls 13

IsLocalMethod · 0.95
CurrentVersionMethod · 0.95
LatestVersionMethod · 0.95
UpdateDirMethod · 0.95
NameMethod · 0.95
setStateEntryFunction · 0.85
CheckForExtensionUpdateFunction · 0.85
getStateEntryFunction · 0.85
JoinMethod · 0.80
EqualMethod · 0.80
AddMethod · 0.65
RunMethod · 0.65

Tested by

no test coverage detected