-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #80 from steffenfritz/add_tests
Add tests
- Loading branch information
Showing
3 changed files
with
90 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package filetrove | ||
|
||
import ( | ||
"reflect" | ||
"testing" | ||
) | ||
|
||
func TestExifDecode(t *testing.T) { | ||
type args struct { | ||
fileName string | ||
} | ||
tests := []struct { | ||
name string | ||
args args | ||
want ExifParsed | ||
wantErr bool | ||
}{ | ||
{"EXIF screenshot_1.jpg", args{"testdata/images/screenshot_1.jpeg"}, ExifParsed{Artist: "\"Steffen Fritz\""}, false}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
got, err := ExifDecode(tt.args.fileName) | ||
if (err != nil) != tt.wantErr { | ||
t.Errorf("ExifDecode() error = %v, wantErr %v", err, tt.wantErr) | ||
return | ||
} | ||
if !reflect.DeepEqual(got.Artist, tt.want.Artist) { | ||
t.Errorf("ExifDecode() got = %v, want %v", got.Artist, tt.want.Artist) | ||
} | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package filetrove | ||
|
||
import ( | ||
"reflect" | ||
"testing" | ||
"time" | ||
) | ||
|
||
func TestGetFileTimes(t *testing.T) { | ||
type args struct { | ||
filename string | ||
} | ||
tests := []struct { | ||
name string | ||
args args | ||
want FileTime | ||
wantErr bool | ||
}{ | ||
{"File Time white.jpg", args{"testdata/white.jpg"}, FileTime{Btime: time.Date(2024, time.January, 29, 18, 21, 29, 146356207, time.Local)}, false}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
got, err := GetFileTimes(tt.args.filename) | ||
if (err != nil) != tt.wantErr { | ||
t.Errorf("GetFileTimes() error = %v, wantErr %v", err, tt.wantErr) | ||
return | ||
} | ||
if !reflect.DeepEqual(got.Btime, tt.want.Btime) { | ||
t.Errorf("GetFileTimes() got = %v, want %v", got.Btime, tt.want.Btime) | ||
} | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package filetrove | ||
|
||
import "testing" | ||
|
||
func TestCreateUUID(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
want int | ||
wantErr bool | ||
}{ | ||
{"UUID length", 36, false}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
got, err := CreateUUID() | ||
if (err != nil) != tt.wantErr { | ||
t.Errorf("CreateUUID() error = %v, wantErr %v", err, tt.wantErr) | ||
return | ||
} | ||
if len(got) != tt.want { | ||
t.Errorf("CreateUUID() got = %v, want %v", len(got), tt.want) | ||
} | ||
}) | ||
} | ||
} |