From dc6aab4910c589e1e37e7cb93d65a1195fbbca1f Mon Sep 17 00:00:00 2001 From: RanXom Date: Mon, 13 Jul 2026 14:30:34 +0530 Subject: test: add shared fixture helpers --- internal/gallery/builder_test.go | 6 +++--- internal/metadata/reader_test.go | 10 +++++----- internal/testfixtures/fixtures.go | 16 ++++++++++++++++ 3 files changed, 24 insertions(+), 8 deletions(-) create mode 100644 internal/testfixtures/fixtures.go diff --git a/internal/gallery/builder_test.go b/internal/gallery/builder_test.go index 91fa4ae..634bd89 100644 --- a/internal/gallery/builder_test.go +++ b/internal/gallery/builder_test.go @@ -2,12 +2,12 @@ package gallery import ( "context" - "path/filepath" "testing" "time" "github.com/RanXom/galleryd/internal/metadata" "github.com/RanXom/galleryd/internal/scanner" + "github.com/RanXom/galleryd/internal/testfixtures" ) func TestBuilder(t *testing.T) { @@ -17,7 +17,7 @@ func TestBuilder(t *testing.T) { t.Run("builds gallery photos", func(t *testing.T) { files := []scanner.File{ { - Path: filepath.Join("..", "testfixtures", "Canon_40D.jpg"), + Path: testfixtures.Canon40D(), Root: "testfixtures", RelativePath: "Canon_40D.jpg", ModTime: time.Now(), @@ -36,7 +36,7 @@ func TestBuilder(t *testing.T) { t.Run("generates deterministic ids", func(t *testing.T) { file := scanner.File{ - Path: filepath.Join("..", "testfixtures", "Canon_40D.jpg"), + Path: testfixtures.Canon40D(), Root: "photos", RelativePath: "Canon_40D.jpg", ModTime: time.Now(), diff --git a/internal/metadata/reader_test.go b/internal/metadata/reader_test.go index 0c9637b..772f078 100644 --- a/internal/metadata/reader_test.go +++ b/internal/metadata/reader_test.go @@ -2,11 +2,11 @@ package metadata import ( "context" - "path/filepath" "testing" "time" "github.com/RanXom/galleryd/internal/scanner" + "github.com/RanXom/galleryd/internal/testfixtures" ) func TestReader(t *testing.T) { @@ -14,7 +14,7 @@ func TestReader(t *testing.T) { t.Run("reads image dimensions", func(t *testing.T) { file := scanner.File{ - Path: filepath.Join("..", "testfixtures", "Canon_40D.jpg"), + Path: testfixtures.Canon40D(), } metadata, err := reader.Read(context.Background(), file) @@ -29,7 +29,7 @@ func TestReader(t *testing.T) { t.Run("reads EXIF timestamp", func(t *testing.T) { file := scanner.File{ - Path: filepath.Join("..", "testfixtures", "Canon_40D.jpg"), + Path: testfixtures.Canon40D(), } metadata, err := reader.Read(context.Background(), file) @@ -57,7 +57,7 @@ func TestReader(t *testing.T) { ) file := scanner.File{ - Path: filepath.Join("..", "testfixtures", "no-exif.png"), + Path: testfixtures.NoEXIF(), ModTime: modTime, } @@ -77,7 +77,7 @@ func TestReader(t *testing.T) { t.Run("returns default orientation", func(t *testing.T) { file := scanner.File{ - Path: filepath.Join("..", "testfixtures", "no-exif.png"), + Path: testfixtures.NoEXIF(), } metadata, err := reader.Read(context.Background(), file) diff --git a/internal/testfixtures/fixtures.go b/internal/testfixtures/fixtures.go new file mode 100644 index 0000000..57ebb61 --- /dev/null +++ b/internal/testfixtures/fixtures.go @@ -0,0 +1,16 @@ +// Package testfixtures holds shared fixture helpers +package testfixtures + +import "path/filepath" + +func Canon40D() string { + return filepath.Join("..", "testfixtures", "Canon_40D.jpg") +} + +func NikonD70() string { + return filepath.Join("..", "testfixtures", "Nikon_D70.jpg") +} + +func NoEXIF() string { + return filepath.Join("..", "testfixtures", "no-exif.png") +} -- cgit v1.2.3