-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsync_test.go
51 lines (43 loc) · 1.38 KB
/
sync_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package main
import (
"testing"
photoslibrary "evgenykuznetsov.org/go/gphotoslibrary"
)
var (
testLib = Library{
Path: "/some/path/",
Deduplicator: dedupUnixHex,
}
testMetadata = photoslibrary.MediaMetadata{
CreationTime: "2006-01-02T15:04:05Z",
}
testItem = photoslibrary.MediaItem{
Filename: "20060102_150405.mp4",
MediaMetadata: &testMetadata,
Id: "AAJ-kdRYAOoSLowCcySWIOXkQzV_HTy78NjW9Sfq5OLf596iz09YdIpL4vO3KVW1uMJ7zhtpHWf7KcpAzudOyHjgiZNgiPRGuQ",
}
)
func TestDeduplicatePath(t *testing.T) {
t.Run("-gphotosync-UnixHex.ext", func(t *testing.T) {
got, _ := deduplicatePath(&testLib, &testItem)
want := "/some/path/2006/01/20060102_150405-gphotosync-fc4a4d5fdf6b200.mp4"
assertCorrectMessage(t, got, want)
})
t.Run("-gphotosync-id.ext", func(t *testing.T) {
testLib.Deduplicator = dedupID
got, _ := deduplicatePath(&testLib, &testItem)
want := "/some/path/2006/01/20060102_150405-gphotosync-AAJ-kdRYAOoSLowCcySWIOXkQzV_HTy78NjW9Sfq5OLf596iz09YdIpL4vO3KVW1uMJ7zhtpHWf7KcpAzudOyHjgiZNgiPRGuQ.mp4"
assertCorrectMessage(t, got, want)
})
}
func TestGetMediaPath(t *testing.T) {
got, _ := getMediaPath(&testLib, &testItem)
want := "/some/path/2006/01/20060102_150405.mp4"
assertCorrectMessage(t, got, want)
}
func assertCorrectMessage(t *testing.T, got, want string) {
t.Helper()
if got != want {
t.Errorf("got %q want %q", got, want)
}
}