ref(git): replace git's native -sort with a thrid-party function

Signed-off-by: storyicon <storyicon@foxmail.com>
This commit is contained in:
storyicon 2021-08-01 17:11:54 +08:00
parent 3953017597
commit 7b2c0762d4
7 changed files with 95 additions and 62 deletions

View file

@ -84,4 +84,39 @@ func TestDeduplicateSliceStably(t *testing.T) {
}
})
}
}
}
func TestSortSemanticVersion(t *testing.T) {
type args struct {
items []string
}
tests := []struct {
name string
args args
want []string
want1 []string
}{
{
args: args{
items: []string{
"v3.0.0-beta-3.1",
"v3.0.0-alpha-2",
"3.15.0-rc1", "conformance-build-tag", "v2.4.1",
},
},
want: []string{"conformance-build-tag"},
want1: []string{"v2.4.1", "v3.0.0-alpha-2", "v3.0.0-beta-3.1", "3.15.0-rc1"},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, got1 := SortSemanticVersion(tt.args.items)
if !reflect.DeepEqual(got, tt.want) {
t.Errorf("SortSemanticVersion() got = %v, want %v", got, tt.want)
}
if !reflect.DeepEqual(got1, tt.want1) {
t.Errorf("SortSemanticVersion() got1 = %v, want %v", got1, tt.want1)
}
})
}
}