mirror of https://github.com/dsoprea/go-exif.git
Minor sensible testing refactors
parent
a350bacdac
commit
ca8584a0e1
|
@ -11,11 +11,10 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
assetsPath = ""
|
|
||||||
testImageFilepath = ""
|
|
||||||
testExifData = make([]byte, 0)
|
|
||||||
moduleRootPath = ""
|
moduleRootPath = ""
|
||||||
|
|
||||||
|
testExifData []byte = nil
|
||||||
|
|
||||||
// EncodeDefaultByteOrder is the default byte-order for encoding operations.
|
// EncodeDefaultByteOrder is the default byte-order for encoding operations.
|
||||||
EncodeDefaultByteOrder = binary.BigEndian
|
EncodeDefaultByteOrder = binary.BigEndian
|
||||||
|
|
||||||
|
@ -24,10 +23,7 @@ var (
|
||||||
)
|
)
|
||||||
|
|
||||||
func GetModuleRootPath() string {
|
func GetModuleRootPath() string {
|
||||||
if moduleRootPath != "" {
|
if moduleRootPath == "" {
|
||||||
return moduleRootPath
|
|
||||||
}
|
|
||||||
|
|
||||||
moduleRootPath := os.Getenv("EXIF_MODULE_ROOT_PATH")
|
moduleRootPath := os.Getenv("EXIF_MODULE_ROOT_PATH")
|
||||||
if moduleRootPath != "" {
|
if moduleRootPath != "" {
|
||||||
return moduleRootPath
|
return moduleRootPath
|
||||||
|
@ -57,35 +53,35 @@ func GetModuleRootPath() string {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return currentPath
|
moduleRootPath = currentPath
|
||||||
}
|
}
|
||||||
|
|
||||||
func getTestAssetsPath() string {
|
return moduleRootPath
|
||||||
if assetsPath == "" {
|
|
||||||
moduleRootPath := GetModuleRootPath()
|
|
||||||
assetsPath = path.Join(moduleRootPath, "assets")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GetTestAssetsPath() string {
|
||||||
|
moduleRootPath := GetModuleRootPath()
|
||||||
|
assetsPath := path.Join(moduleRootPath, "assets")
|
||||||
|
|
||||||
return assetsPath
|
return assetsPath
|
||||||
}
|
}
|
||||||
|
|
||||||
func getTestImageFilepath() string {
|
func getTestImageFilepath() string {
|
||||||
if testImageFilepath == "" {
|
assetsPath := GetTestAssetsPath()
|
||||||
assetsPath := getTestAssetsPath()
|
testImageFilepath := path.Join(assetsPath, "NDM_8901.jpg")
|
||||||
testImageFilepath = path.Join(assetsPath, "NDM_8901.jpg")
|
|
||||||
}
|
|
||||||
|
|
||||||
return testImageFilepath
|
return testImageFilepath
|
||||||
}
|
}
|
||||||
|
|
||||||
func getTestExifData() []byte {
|
func getTestExifData() []byte {
|
||||||
assetsPath := getTestAssetsPath()
|
if testExifData == nil {
|
||||||
|
assetsPath := GetTestAssetsPath()
|
||||||
filepath := path.Join(assetsPath, "NDM_8901.jpg.exif")
|
filepath := path.Join(assetsPath, "NDM_8901.jpg.exif")
|
||||||
|
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
testExifData, err = ioutil.ReadFile(filepath)
|
testExifData, err = ioutil.ReadFile(filepath)
|
||||||
log.PanicIf(err)
|
log.PanicIf(err)
|
||||||
|
}
|
||||||
|
|
||||||
return testExifData
|
return testExifData
|
||||||
}
|
}
|
||||||
|
|
|
@ -217,6 +217,7 @@ func TestIfd_Thumbnail(t *testing.T) {
|
||||||
actual, err := ifd.NextIfd.Thumbnail()
|
actual, err := ifd.NextIfd.Thumbnail()
|
||||||
log.PanicIf(err)
|
log.PanicIf(err)
|
||||||
|
|
||||||
|
assetsPath := exifcommon.GetTestAssetsPath()
|
||||||
expectedFilepath := path.Join(assetsPath, "NDM_8901.jpg.thumbnail")
|
expectedFilepath := path.Join(assetsPath, "NDM_8901.jpg.thumbnail")
|
||||||
|
|
||||||
expected, err := ioutil.ReadFile(expectedFilepath)
|
expected, err := ioutil.ReadFile(expectedFilepath)
|
||||||
|
@ -277,7 +278,7 @@ func TestIfd_GpsInfo__2_0_0_0(t *testing.T) {
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
assetsPath := getTestAssetsPath()
|
assetsPath := exifcommon.GetTestAssetsPath()
|
||||||
filepath := path.Join(assetsPath, "gps-2000-scaled.jpg")
|
filepath := path.Join(assetsPath, "gps-2000-scaled.jpg")
|
||||||
|
|
||||||
rawExif, err := SearchFileAndExtractExif(filepath)
|
rawExif, err := SearchFileAndExtractExif(filepath)
|
||||||
|
|
|
@ -13,11 +13,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
assetsPath = ""
|
testExifData []byte = nil
|
||||||
testImageFilepath = ""
|
|
||||||
testGpsImageFilepath = ""
|
|
||||||
|
|
||||||
testExifData = make([]byte, 0)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func getExifSimpleTestIb() *IfdBuilder {
|
func getExifSimpleTestIb() *IfdBuilder {
|
||||||
|
@ -159,41 +155,28 @@ func validateExifSimpleTestIb(exifData []byte, t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func getTestAssetsPath() string {
|
|
||||||
if assetsPath == "" {
|
|
||||||
moduleRootPath := exifcommon.GetModuleRootPath()
|
|
||||||
assetsPath = path.Join(moduleRootPath, "assets")
|
|
||||||
}
|
|
||||||
|
|
||||||
return assetsPath
|
|
||||||
}
|
|
||||||
|
|
||||||
func getTestImageFilepath() string {
|
func getTestImageFilepath() string {
|
||||||
if testImageFilepath == "" {
|
assetsPath := exifcommon.GetTestAssetsPath()
|
||||||
assetsPath := getTestAssetsPath()
|
testImageFilepath := path.Join(assetsPath, "NDM_8901.jpg")
|
||||||
testImageFilepath = path.Join(assetsPath, "NDM_8901.jpg")
|
|
||||||
}
|
|
||||||
|
|
||||||
return testImageFilepath
|
return testImageFilepath
|
||||||
}
|
}
|
||||||
|
|
||||||
func getTestExifData() []byte {
|
func getTestExifData() []byte {
|
||||||
assetsPath := getTestAssetsPath()
|
if testExifData == nil {
|
||||||
|
assetsPath := exifcommon.GetTestAssetsPath()
|
||||||
filepath := path.Join(assetsPath, "NDM_8901.jpg.exif")
|
filepath := path.Join(assetsPath, "NDM_8901.jpg.exif")
|
||||||
|
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
testExifData, err = ioutil.ReadFile(filepath)
|
testExifData, err = ioutil.ReadFile(filepath)
|
||||||
log.PanicIf(err)
|
log.PanicIf(err)
|
||||||
|
}
|
||||||
|
|
||||||
return testExifData
|
return testExifData
|
||||||
}
|
}
|
||||||
|
|
||||||
func getTestGpsImageFilepath() string {
|
func getTestGpsImageFilepath() string {
|
||||||
if testGpsImageFilepath == "" {
|
assetsPath := exifcommon.GetTestAssetsPath()
|
||||||
assetsPath := getTestAssetsPath()
|
testGpsImageFilepath := path.Join(assetsPath, "gps.jpg")
|
||||||
testGpsImageFilepath = path.Join(assetsPath, "gps.jpg")
|
|
||||||
}
|
|
||||||
|
|
||||||
return testGpsImageFilepath
|
return testGpsImageFilepath
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue