MCPcopy Index your code
hub / github.com/coder/coder / TestSortVersionsDesc

Function TestSortVersionsDesc

scripts/releaser/version_test.go:169–240  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

167}
168
169func TestSortVersionsDesc(t *testing.T) {
170 t.Parallel()
171
172 tests := []struct {
173 name string
174 input []version
175 want []version
176 }{
177 {
178 // This is the exact scenario that triggered the bug:
179 // git's --sort=-v:refname places v2.32.0-rc.0 before
180 // v2.32.0, but semver says v2.32.0 > v2.32.0-rc.0.
181 name: "release_sorts_before_rc",
182 input: []version{
183 {2, 32, 0, "rc.0"},
184 {2, 32, 0, ""},
185 {2, 31, 2, ""},
186 },
187 want: []version{
188 {2, 32, 0, ""},
189 {2, 32, 0, "rc.0"},
190 {2, 31, 2, ""},
191 },
192 },
193 {
194 name: "multiple_rcs_and_releases",
195 input: []version{
196 {2, 33, 0, "rc.1"},
197 {2, 33, 0, "rc.0"},
198 {2, 32, 0, "rc.0"},
199 {2, 32, 0, ""},
200 {2, 32, 1, ""},
201 {2, 31, 0, ""},
202 },
203 want: []version{
204 {2, 33, 0, "rc.1"},
205 {2, 33, 0, "rc.0"},
206 {2, 32, 1, ""},
207 {2, 32, 0, ""},
208 {2, 32, 0, "rc.0"},
209 {2, 31, 0, ""},
210 },
211 },
212 {
213 name: "already_sorted",
214 input: []version{{3, 0, 0, ""}, {2, 0, 0, ""}, {1, 0, 0, ""}},
215 want: []version{{3, 0, 0, ""}, {2, 0, 0, ""}, {1, 0, 0, ""}},
216 },
217 {
218 name: "empty",
219 input: []version{},
220 want: []version{},
221 },
222 }
223
224 for _, tt := range tests {
225 t.Run(tt.name, func(t *testing.T) {
226 t.Parallel()

Callers

nothing calls this directly

Calls 4

sortVersionsDescFunction · 0.85
RunMethod · 0.65
FatalfMethod · 0.45
EqualMethod · 0.45

Tested by

no test coverage detected