(t *testing.T)
| 123 | } |
| 124 | |
| 125 | func 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 | }, |
nothing calls this directly
no test coverage detected