Is there an existing issue for this?
Current Behavior
When testing a PR I noticed the sort doesn't work for version numbers.
I was testing with updatecli with an update from v0.99.0 to v0.100.0
The version numbers where outputted in the following order:
- v0.100.0
- v0.101.0
- v0.99.0
Expected Behavior
- v0.101.0
- v0.100.0
- v0.99.0
Steps To Reproduce
pkg/core/reports/action_test.go
func TestToActionSort(t *testing.T) {
tests := []struct {
name string
report Action
expectedOutput Action
}{
{
name: "version sort",
report: Action{
Targets: []ActionTarget{
{
Changelogs: []ActionTargetChangelog{
{
Title: "v0.100.0",
},
{
Title: "v0.99.0",
},
{
Title: "v0.101.0",
},
},
},
},
},
expectedOutput: Action{
Targets: []ActionTarget{
{
Changelogs: []ActionTargetChangelog{
{
Title: "v0.101.0",
},
{
Title: "v0.100.0",
},
{
Title: "v0.99.0",
},
},
},
},
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
report := tt.report
report.sort()
assert.Equal(t, tt.expectedOutput, report)
})
}
}
go test
--- FAIL: TestToActionSort (0.00s)
--- FAIL: TestToActionSort/version_sort (0.00s)
action_test.go:638:
Error Trace: /home/matthew/code/src/github.com/updatecli/updatecli/pkg/core/reports/action_test.go:638
Error: Not equal:
expected: reports.Action{ID:"", Title:"", PipelineTitle:"", Description:"", Targets:[]reports.ActionTarget{reports.ActionTarget{ID:"", Title:"", Description:"", Changelogs:[]reports.ActionTargetChangelog{reports.ActionTargetChangelog{Title:"v0.101.0", Description:""}, reports.ActionTargetChangelog{Title:"v0.100.0", Description:""}, reports.ActionTargetChangelog{Title:"v0.99.0", Description:""}}}}, PipelineURL:(*reports.PipelineURL)(nil), Link:""}
actual : reports.Action{ID:"", Title:"", PipelineTitle:"", Description:"", Targets:[]reports.ActionTarget{reports.ActionTarget{ID:"", Title:"", Description:"", Changelogs:[]reports.ActionTargetChangelog{reports.ActionTargetChangelog{Title:"v0.100.0", Description:""}, reports.ActionTargetChangelog{Title:"v0.101.0", Description:""}, reports.ActionTargetChangelog{Title:"v0.99.0", Description:""}}}}, PipelineURL:(*reports.PipelineURL)(nil), Link:""}
Diff:
--- Expected
+++ Actual
@@ -12,3 +12,3 @@
(reports.ActionTargetChangelog) {
- Title: (string) (len=8) "v0.101.0",
+ Title: (string) (len=8) "v0.100.0",
Description: (string) ""
@@ -16,3 +16,3 @@
(reports.ActionTargetChangelog) {
- Title: (string) (len=8) "v0.100.0",
+ Title: (string) (len=8) "v0.101.0",
Description: (string) ""
Test: TestToActionSort/version_sort
FAIL
exit status 1
FAIL github.com/updatecli/updatecli/pkg/core/reports 0.008s
Environment
- OS: WSL Debian
- updatecli: v0.101.0
Is there an existing issue for this?
Current Behavior
When testing a PR I noticed the sort doesn't work for version numbers.
I was testing with updatecli with an update from v0.99.0 to v0.100.0
The version numbers where outputted in the following order:
Expected Behavior
Steps To Reproduce
pkg/core/reports/action_test.goEnvironment