Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ayoisaiah committed Oct 2, 2024
1 parent 19dea56 commit 9e8b8b8
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 45 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: Run tests

on:
workflow_dispatch:
push:
pull_request:
branches:
Expand All @@ -21,5 +22,8 @@ jobs:
with:
go-version: 1.23

- name: Use Exiftool
uses: woss/[email protected]

- name: Run tests
run: go test ./... -race
4 changes: 4 additions & 0 deletions app/app_test/app_unix_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package app_test
import (
"os"
"os/exec"
"slices"
"testing"

"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -84,6 +85,9 @@ func TestPipingInputFromFind(t *testing.T) {

got := os.Args[len(os.Args)-len(tc.expected):]

slices.Sort(got)
slices.Sort(tc.expected)

assert.Equal(t, tc.expected, got)
})
}
Expand Down
47 changes: 2 additions & 45 deletions internal/sortfiles/sortfiles_test/sortfiles_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,57 +238,18 @@ func TestSortFiles_BySize(t *testing.T) {
ReverseSort: true,
},
{
Name: "sort recursively with only directories",
Unsorted: []string{
"testdata/dir1/folder",
"testdata/dir1",
},
Sorted: []string{
"testdata/dir1/folder",
"testdata/dir1",
},
},
{
Name: "sort recursively in reverse with only directories",
Unsorted: []string{
"testdata/dir1/folder",
"testdata/dir1",
},
Sorted: []string{
"testdata/dir1",
"testdata/dir1/folder",
},
ReverseSort: true,
},
{
Name: "sort size recursively with only directories and --sort-per-dir",
Unsorted: []string{
"testdata/dir1/folder",
"testdata/dir1",
},
Sorted: []string{
"testdata/dir1",
"testdata/dir1/folder",
},
SortPerDir: true,
},
{
Name: "sort files and directories without --sort-per-dir",
Name: "sort files without --sort-per-dir",
Unsorted: []string{
"testdata/dir1/folder/15k.txt",
"testdata/20k.txt",
"testdata/dir1",
"testdata/4k.txt",
"testdata/dir1/folder",
"testdata/dir1/folder/3k.txt",
"testdata/11k.txt",
"testdata/10k.txt",
"testdata/dir1/20k.txt",
"testdata/dir1/10k.txt",
},
Sorted: []string{
"testdata/dir1/folder",
"testdata/dir1",
"testdata/dir1/folder/3k.txt",
"testdata/4k.txt",
"testdata/10k.txt",
Expand All @@ -300,26 +261,22 @@ func TestSortFiles_BySize(t *testing.T) {
},
},
{
Name: "sort files and directories with --sort-per-dir",
Name: "sort files with --sort-per-dir",
Unsorted: []string{
"testdata/dir1/folder/15k.txt",
"testdata/20k.txt",
"testdata/dir1",
"testdata/4k.txt",
"testdata/dir1/folder",
"testdata/dir1/folder/3k.txt",
"testdata/11k.txt",
"testdata/10k.txt",
"testdata/dir1/20k.txt",
"testdata/dir1/10k.txt",
},
Sorted: []string{
"testdata/dir1",
"testdata/4k.txt",
"testdata/10k.txt",
"testdata/11k.txt",
"testdata/20k.txt",
"testdata/dir1/folder",
"testdata/dir1/10k.txt",
"testdata/dir1/20k.txt",
"testdata/dir1/folder/3k.txt",
Expand Down

0 comments on commit 9e8b8b8

Please sign in to comment.