Skip to content

Commit

Permalink
add some more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ayoisaiah committed Nov 1, 2024
1 parent 05a699c commit 05950aa
Show file tree
Hide file tree
Showing 25 changed files with 87 additions and 0 deletions.
60 changes: 60 additions & 0 deletions f2_test/f2_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package f2_test

import (
"bytes"
"testing"

"github.com/ayoisaiah/f2"
"github.com/ayoisaiah/f2/internal/config"
"github.com/ayoisaiah/f2/internal/testutil"
)

func TestImagePairRenaming(t *testing.T) {
var stdout bytes.Buffer

var stdin bytes.Buffer

var stderr bytes.Buffer

app, err := f2.New(&stdin, &stdout)
if err != nil {
t.Fatal(err)
}

config.Stderr = &stderr

err = app.Run([]string{
"f2_test",
"-r",
"{x.cdt.YYYY}/{x.cdt.MM}-{x.cdt.MMM}/{x.cdt.YYYY}-{x.cdt.MM}-{x.cdt.DD}/{%03d}",
"-R",
"--target-dir",
".",
"--pair",
"--reset-index-per-dir",
"-F",
"--fix-conflicts-pattern",
"%03d",
"--sort",
"time_var",
"--sort-var",
"{x.cdt}",
"--pair-order",
"dng,jpg",
"--exclude",
"golden",
"testdata",
})
if err != nil {
t.Fatal(err)
}

tc := &testutil.TestCase{
Name: "image pair renaming",
}

tc.SnapShot.Stdout = stdout.Bytes()
tc.SnapShot.Stderr = stderr.Bytes()

testutil.CompareGoldenFile(t, tc)
}
Binary file added f2_test/testdata/birthday-2024/img44.dng
Binary file not shown.
Binary file added f2_test/testdata/birthday-2024/img44.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added f2_test/testdata/birthday-2024/img78.dng
Binary file not shown.
Binary file added f2_test/testdata/birthday-2024/img78.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added f2_test/testdata/family trip - berlin/img101.dng
Binary file not shown.
Binary file added f2_test/testdata/family trip - berlin/img101.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added f2_test/testdata/family trip - berlin/img90.dng
Binary file not shown.
Binary file added f2_test/testdata/family trip - berlin/img90.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added f2_test/testdata/family trip - berlin/img99.dng
Binary file not shown.
Binary file added f2_test/testdata/family trip - berlin/img99.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added f2_test/testdata/family trip - london/img1.dng
Binary file not shown.
Binary file added f2_test/testdata/family trip - london/img1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added f2_test/testdata/family trip - london/img2.dng
Binary file not shown.
Binary file added f2_test/testdata/family trip - london/img2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions f2_test/testdata/image_pair_renaming_stderr.golden
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dry run: commit the above changes with the -x/--exec flag
26 changes: 26 additions & 0 deletions f2_test/testdata/image_pair_renaming_stdout.golden
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
*——————————————————————————————————————————*————————————————————————————————*————————*
| ORIGINAL | RENAMED | STATUS |
*——————————————————————————————————————————*————————————————————————————————*————————*
| testdata/family trip - london/img1.dng | 2024/05-May/2024-05-30/001.dng | ok |
| testdata/family trip - london/img1.jpg | 2024/05-May/2024-05-30/001.jpg | ok |
| testdata/family trip - london/img2.dng | 2024/05-May/2024-05-30/002.dng | ok |
| testdata/family trip - london/img2.jpg | 2024/05-May/2024-05-30/002.jpg | ok |
| testdata/family trip - berlin/img90.dng | 2024/06-Jun/2024-06-27/001.dng | ok |
| testdata/family trip - berlin/img90.jpg | 2024/06-Jun/2024-06-27/001.jpg | ok |
| testdata/family trip - berlin/img99.dng | 2024/06-Jun/2024-06-27/002.dng | ok |
| testdata/family trip - berlin/img99.jpg | 2024/06-Jun/2024-06-27/002.jpg | ok |
| testdata/family trip - berlin/img101.dng | 2024/06-Jun/2024-06-27/003.dng | ok |
| testdata/family trip - berlin/img101.jpg | 2024/06-Jun/2024-06-27/003.jpg | ok |
| testdata/img34.dng | 2024/06-Jun/2024-06-28/001.dng | ok |
| testdata/img34.jpg | 2024/06-Jun/2024-06-28/001.jpg | ok |
| testdata/img66.dng | 2024/06-Jun/2024-06-28/002.dng | ok |
| testdata/img66.jpg | 2024/06-Jun/2024-06-28/002.jpg | ok |
| testdata/birthday-2024/img44.dng | 2024/06-Jun/2024-06-28/003.dng | ok |
| testdata/birthday-2024/img44.jpg | 2024/06-Jun/2024-06-28/003.jpg | ok |
| testdata/birthday-2024/img78.dng | 2024/06-Jun/2024-06-28/004.dng | ok |
| testdata/birthday-2024/img78.jpg | 2024/06-Jun/2024-06-28/004.jpg | ok |
| testdata/my-wedding/img33.dng | 2024/07-Jul/2024-07-02/001.dng | ok |
| testdata/my-wedding/img33.jpg | 2024/07-Jul/2024-07-02/001.jpg | ok |
| testdata/my-wedding/img67.dng | 2024/07-Jul/2024-07-02/002.dng | ok |
| testdata/my-wedding/img67.jpg | 2024/07-Jul/2024-07-02/002.jpg | ok |
*——————————————————————————————————————————*————————————————————————————————*————————*
Binary file added f2_test/testdata/img34.dng
Binary file not shown.
Binary file added f2_test/testdata/img34.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added f2_test/testdata/img66.dng
Binary file not shown.
Binary file added f2_test/testdata/img66.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added f2_test/testdata/my-wedding/img33.dng
Binary file not shown.
Binary file added f2_test/testdata/my-wedding/img33.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added f2_test/testdata/my-wedding/img67.dng
Binary file not shown.
Binary file added f2_test/testdata/my-wedding/img67.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 05950aa

Please sign in to comment.