Skip to content

Commit

Permalink
fix(export): improve matching (#69)
Browse files Browse the repository at this point in the history
* fix(export): always compare hashes lowercase

* fix(export): improve ext compare and logs

* fix(export): failing test

* feat(export): create export dir if not exists

* feat(export): rename test export funs

* refactor(export): move dir exists check

* refactor(export): process
  • Loading branch information
ludviglundgren authored Aug 25, 2023
1 parent 3ecab14 commit 20133e0
Show file tree
Hide file tree
Showing 4 changed files with 311 additions and 162 deletions.
150 changes: 0 additions & 150 deletions cmd/export.go

This file was deleted.

27 changes: 15 additions & 12 deletions cmd/export_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,36 @@ package cmd

import "testing"

func Test_processHashes(t *testing.T) {
func Test_export_processHashes(t *testing.T) {
type args struct {
sourceDir string
exportDir string
hashes map[string]struct{}
replace []string
dry bool
verbose bool
}
tests := []struct {
name string
args args
wantErr bool
}{
{name: "test_1", args: args{
sourceDir: "../test/config/qBittorrent/BT_backup",
exportDir: "../test/export",
hashes: map[string]struct{}{
"5ba4939a00a9b21629a0ad7d376898b768d997a3": {},
{
name: "test_1",
args: args{
sourceDir: "../test/config/qBittorrent/BT_backup",
exportDir: "../test/export",
hashes: map[string]struct{}{
"5ba4939a00a9b21629a0ad7d376898b768d997a3": {},
},
dry: false,
},
replace: []string{"https://academictorrents.com/announce.php|https://test.com/announce.php?test"},
dry: false,
}, wantErr: false},
wantErr: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if err := processHashes(tt.args.sourceDir, tt.args.exportDir, tt.args.hashes, tt.args.dry); (err != nil) != tt.wantErr {
t.Errorf("processHashes() error = %v, wantErr %v", err, tt.wantErr)
if err := processExport(tt.args.sourceDir, tt.args.exportDir, tt.args.hashes, tt.args.dry, tt.args.verbose); (err != nil) != tt.wantErr {
t.Errorf("processExport() error = %v, wantErr %v", err, tt.wantErr)
}
})
}
Expand Down
Loading

0 comments on commit 20133e0

Please sign in to comment.