simplified string sorting by using a more suitable function

This commit is contained in:
Alexandr Bruyako 2019-06-30 23:20:32 +03:00
parent 3ca424050f
commit 16eeed2ad5
4 changed files with 10 additions and 10 deletions

View file

@ -116,8 +116,8 @@ func TestDefaultLayout(t *testing.T) {
want = append(want, filepath.Join(tempdir, "data", fmt.Sprintf("%02x", i)))
}
sort.Sort(sort.StringSlice(want))
sort.Sort(sort.StringSlice(dirs))
sort.Strings(want)
sort.Strings(dirs)
if !reflect.DeepEqual(dirs, want) {
t.Fatalf("wrong paths returned, want:\n %v\ngot:\n %v", want, dirs)
@ -189,8 +189,8 @@ func TestRESTLayout(t *testing.T) {
filepath.Join(path, "keys"),
}
sort.Sort(sort.StringSlice(want))
sort.Sort(sort.StringSlice(dirs))
sort.Strings(want)
sort.Strings(dirs)
if !reflect.DeepEqual(dirs, want) {
t.Fatalf("wrong paths returned, want:\n %v\ngot:\n %v", want, dirs)
@ -335,8 +335,8 @@ func TestS3LegacyLayout(t *testing.T) {
filepath.Join(path, "key"),
}
sort.Sort(sort.StringSlice(want))
sort.Sort(sort.StringSlice(dirs))
sort.Strings(want)
sort.Strings(dirs)
if !reflect.DeepEqual(dirs, want) {
t.Fatalf("wrong paths returned, want:\n %v\ngot:\n %v", want, dirs)

View file

@ -72,8 +72,8 @@ func verifyDirectoryContents(t testing.TB, fs FS, dir string, want []string) {
t.Fatal(err)
}
sort.Sort(sort.StringSlice(want))
sort.Sort(sort.StringSlice(entries))
sort.Strings(want)
sort.Strings(entries)
if !cmp.Equal(want, entries) {
t.Error(cmp.Diff(want, entries))

View file

@ -176,7 +176,7 @@ func (b *Backup) update(total, processed counter, errors uint, currentFiles map[
for filename := range currentFiles {
lines = append(lines, filename)
}
sort.Sort(sort.StringSlice(lines))
sort.Strings(lines)
lines = append([]string{status}, lines...)
b.term.SetStatus(lines)

View file

@ -159,7 +159,7 @@ func (b *Backup) update(total, processed counter, errors uint, currentFiles map[
for filename := range currentFiles {
status.CurrentFiles = append(status.CurrentFiles, filename)
}
sort.Sort(sort.StringSlice(status.CurrentFiles))
sort.Strings(status.CurrentFiles)
json.NewEncoder(b.StdioWrapper.Stdout()).Encode(status)
}