Skip to content

Commit

Permalink
fix file path for download images
Browse files Browse the repository at this point in the history
  • Loading branch information
Monirzadeh committed Feb 4, 2024
1 parent 2832fd1 commit 266685c
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions internal/core/processing_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"context"
"net/http"
"net/http/httptest"
"path/filepath"
"testing"

"github.com/go-shiori/shiori/internal/core"
Expand All @@ -23,7 +24,7 @@ func TestDownloadBookImage(t *testing.T) {
// images is too small with unsupported format with a valid URL
imageURL := "https://github.com/go-shiori/shiori/blob/master/internal/view/assets/res/apple-touch-icon-152x152.png"
temp := t.TempDir()
dstFile := temp + "/image.png"
dstFile := filepath.Join(temp + "image.png")

// Act
err := core.DownloadBookImage(deps, imageURL, dstFile)
Expand All @@ -33,9 +34,10 @@ func TestDownloadBookImage(t *testing.T) {
assert.False(t, deps.Domains.Storage.FileExists(dstFile))
})
t.Run("successful download image", func(t *testing.T) {
temp := t.TempDir()
// Arrange
imageURL := "https://raw.githubusercontent.com/go-shiori/shiori/master/docs/readme/cover.png"
dstFile := "tempDir/image.png"
dstFile := filepath.Join(temp + "image.png")

// Act
err := core.DownloadBookImage(deps, imageURL, dstFile)
Expand All @@ -45,6 +47,7 @@ func TestDownloadBookImage(t *testing.T) {
assert.True(t, deps.Domains.Storage.FileExists(dstFile))
})
t.Run("successful download medium size image", func(t *testing.T) {
temp := t.TempDir()
// create a file server handler for the 'testdata' directory
fs := http.FileServer(http.Dir("../../testdata/"))

Expand All @@ -54,7 +57,7 @@ func TestDownloadBookImage(t *testing.T) {

// Arrange
imageURL := server.URL + "/medium_image.png"
dstFile := "tempDir/medium_image.png"
dstFile := filepath.Join(temp + "medium_image.png")

// Act
err := core.DownloadBookImage(deps, imageURL, dstFile)
Expand Down

0 comments on commit 266685c

Please sign in to comment.