From 9e8b8b8ae4b38720a7c79c717ff0c6bb251f75f3 Mon Sep 17 00:00:00 2001 From: Ayooluwa Isaiah Date: Wed, 2 Oct 2024 19:04:38 +0100 Subject: [PATCH] fix tests --- .github/workflows/test.yml | 4 ++ app/app_test/app_unix_test.go | 4 ++ .../sortfiles_test/sortfiles_test.go | 47 +------------------ 3 files changed, 10 insertions(+), 45 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 54fbc42..72974af 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,6 +1,7 @@ name: Run tests on: + workflow_dispatch: push: pull_request: branches: @@ -21,5 +22,8 @@ jobs: with: go-version: 1.23 + - name: Use Exiftool + uses: woss/exiftool-action@v12.92 + - name: Run tests run: go test ./... -race diff --git a/app/app_test/app_unix_test.go b/app/app_test/app_unix_test.go index eb41941..2a71a17 100644 --- a/app/app_test/app_unix_test.go +++ b/app/app_test/app_unix_test.go @@ -6,6 +6,7 @@ package app_test import ( "os" "os/exec" + "slices" "testing" "github.com/stretchr/testify/assert" @@ -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) }) } diff --git a/internal/sortfiles/sortfiles_test/sortfiles_test.go b/internal/sortfiles/sortfiles_test/sortfiles_test.go index 4d38c6d..5358cfb 100644 --- a/internal/sortfiles/sortfiles_test/sortfiles_test.go +++ b/internal/sortfiles/sortfiles_test/sortfiles_test.go @@ -238,48 +238,11 @@ 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", @@ -287,8 +250,6 @@ func TestSortFiles_BySize(t *testing.T) { "testdata/dir1/10k.txt", }, Sorted: []string{ - "testdata/dir1/folder", - "testdata/dir1", "testdata/dir1/folder/3k.txt", "testdata/4k.txt", "testdata/10k.txt", @@ -300,13 +261,11 @@ 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", @@ -314,12 +273,10 @@ func TestSortFiles_BySize(t *testing.T) { "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",