2018-02-04 17:34:07 +01:00
|
|
|
package photoprism
|
|
|
|
|
|
|
|
import (
|
2018-02-27 19:04:48 +01:00
|
|
|
"github.com/stretchr/testify/assert"
|
2018-02-28 10:08:49 +01:00
|
|
|
"testing"
|
2018-02-04 17:34:07 +01:00
|
|
|
)
|
|
|
|
|
2018-02-27 19:04:48 +01:00
|
|
|
func TestNewImporter(t *testing.T) {
|
|
|
|
conf := NewTestConfig()
|
2018-02-04 17:34:07 +01:00
|
|
|
|
2018-02-27 19:04:48 +01:00
|
|
|
importer := NewImporter(conf.OriginalsPath)
|
2018-02-04 17:34:07 +01:00
|
|
|
|
2018-02-27 19:04:48 +01:00
|
|
|
assert.IsType(t, &Importer{}, importer)
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestImporter_ImportPhotosFromDirectory(t *testing.T) {
|
|
|
|
conf := NewTestConfig()
|
|
|
|
|
|
|
|
conf.InitializeTestData(t)
|
|
|
|
|
|
|
|
importer := NewImporter(conf.OriginalsPath)
|
|
|
|
|
|
|
|
importer.ImportPhotosFromDirectory(conf.ImportPath)
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestImporter_GetDestinationFilename(t *testing.T) {
|
|
|
|
conf := NewTestConfig()
|
|
|
|
conf.InitializeTestData(t)
|
|
|
|
importer := NewImporter(conf.OriginalsPath)
|
|
|
|
|
2018-02-28 11:11:26 +01:00
|
|
|
rawFile := NewMediaFile(conf.ImportPath + "/raw/IMG_1435.CR2")
|
2018-02-27 19:04:48 +01:00
|
|
|
|
|
|
|
filename, err := importer.GetDestinationFilename(rawFile, rawFile)
|
|
|
|
|
|
|
|
assert.Empty(t, err)
|
|
|
|
|
2018-02-28 10:08:49 +01:00
|
|
|
assert.Equal(t, conf.OriginalsPath+"/2018/02/20180204_180813_B0770443A5F7.cr2", filename)
|
|
|
|
}
|