fix(download): address lint and test follow-ups
- commit
- 4169f1508d67db8817bcccd8d3755a07f3f21be4
- author
- brice · · 2026-04-19 19:08 UTC
- parent
- ac89917
- signature
- GPG Verified
CD88F9E564E0102646FB6077A1A07C7C7C3E349D· arch-gpg Verified for the committer email
4 files · +9 -7
M internal/infrastructure/cef/download_handler.go +1 -1
| @@ -42,7 +42,7 @@ func newDownloadHandler( | |||
| 42 | 42 | } | |
| 43 | 43 | } | |
| 44 | 44 | ||
| 45 | - | func (h *downloadHandler) canDownload(_ purecef.Browser, _ string, requestMethod string) bool { | |
| 45 | + | func (h *downloadHandler) canDownload(_ purecef.Browser, _, requestMethod string) bool { | |
| 46 | 46 | return requestMethod == "" || strings.EqualFold(requestMethod, http.MethodGet) | |
| 47 | 47 | } | |
| 48 | 48 | ||
| @@ -42,7 +42,7 @@ func newDownloadHandler( | |||||
| 42 | } | 42 | } | ||
| 43 | } | 43 | } | ||
| 44 | 44 | ||||
| 45 | - | func (h *downloadHandler) canDownload(_ purecef.Browser, _ string, requestMethod string) bool { | 45 | + | func (h *downloadHandler) canDownload(_ purecef.Browser, _, requestMethod string) bool { |
| 46 | return requestMethod == "" || strings.EqualFold(requestMethod, http.MethodGet) | 46 | return requestMethod == "" || strings.EqualFold(requestMethod, http.MethodGet) | ||
| 47 | } | 47 | } | ||
| 48 | 48 | ||||
M internal/infrastructure/cef/webview_handlers.go +1 -1
| @@ -814,7 +814,7 @@ func (h *handlerSet) OnBeforeBrowse(browser purecef.Browser, frame purecef.Frame | |||
| 814 | 814 | return true | |
| 815 | 815 | } | |
| 816 | 816 | ||
| 817 | - | func (h *handlerSet) CanDownload(browser purecef.Browser, url string, requestMethod string) bool { | |
| 817 | + | func (h *handlerSet) CanDownload(browser purecef.Browser, url, requestMethod string) bool { | |
| 818 | 818 | handler := h.downloadHandler() | |
| 819 | 819 | if handler == nil { | |
| 820 | 820 | return false | |
| @@ -814,7 +814,7 @@ func (h *handlerSet) OnBeforeBrowse(browser purecef.Browser, frame purecef.Frame | |||||
| 814 | return true | 814 | return true | ||
| 815 | } | 815 | } | ||
| 816 | 816 | ||||
| 817 | - | func (h *handlerSet) CanDownload(browser purecef.Browser, url string, requestMethod string) bool { | 817 | + | func (h *handlerSet) CanDownload(browser purecef.Browser, url, requestMethod string) bool { |
| 818 | handler := h.downloadHandler() | 818 | handler := h.downloadHandler() | ||
| 819 | if handler == nil { | 819 | if handler == nil { | ||
| 820 | return false | 820 | return false | ||
M internal/infrastructure/downloadruntime/runtime_test.go +3 -3
| @@ -15,9 +15,9 @@ type stubResponse struct { | |||
| 15 | 15 | uri string | |
| 16 | 16 | } | |
| 17 | 17 | ||
| 18 | - | func (s stubResponse) GetMimeType() string { return s.mimeType } | |
| 19 | - | func (s stubResponse) GetSuggestedFilename() string { return "" } | |
| 20 | - | func (s stubResponse) GetUri() string { return s.uri } | |
| 18 | + | func (s stubResponse) GetMimeType() string { return s.mimeType } | |
| 19 | + | func (stubResponse) GetSuggestedFilename() string { return "" } | |
| 20 | + | func (s stubResponse) GetUri() string { return s.uri } | |
| 21 | 21 | ||
| 22 | 22 | type captureEvents struct { | |
| 23 | 23 | events []port.DownloadEvent | |
| @@ -15,9 +15,9 @@ type stubResponse struct { | |||||
| 15 | uri string | 15 | uri string | ||
| 16 | } | 16 | } | ||
| 17 | 17 | ||||
| 18 | - | func (s stubResponse) GetMimeType() string { return s.mimeType } | 18 | + | func (s stubResponse) GetMimeType() string { return s.mimeType } |
| 19 | - | func (s stubResponse) GetSuggestedFilename() string { return "" } | 19 | + | func (stubResponse) GetSuggestedFilename() string { return "" } |
| 20 | - | func (s stubResponse) GetUri() string { return s.uri } | 20 | + | func (s stubResponse) GetUri() string { return s.uri } |
| 21 | 21 | ||||
| 22 | type captureEvents struct { | 22 | type captureEvents struct { | ||
| 23 | events []port.DownloadEvent | 23 | events []port.DownloadEvent | ||
M internal/infrastructure/webkit/download_handler_test.go +4 -2
| @@ -2,6 +2,7 @@ package webkit | |||
| 2 | 2 | ||
| 3 | 3 | import ( | |
| 4 | 4 | "context" | |
| 5 | + | "path/filepath" | |
| 5 | 6 | "testing" | |
| 6 | 7 | ||
| 7 | 8 | "github.com/bnema/dumber/internal/application/usecase" | |
| @@ -30,12 +31,13 @@ func TestDownloadHandler_SetDownloadPath(t *testing.T) { | |||
| 30 | 31 | prepareUC := usecase.NewPrepareDownloadUseCase(nil) | |
| 31 | 32 | handler := NewDownloadHandler("/initial/path", nil, prepareUC) | |
| 32 | 33 | ||
| 33 | - | handler.SetDownloadPath("/new/path") | |
| 34 | + | newPath := t.TempDir() | |
| 35 | + | handler.SetDownloadPath(newPath) | |
| 34 | 36 | ||
| 35 | 37 | output, err := handler.runtime.ResolveDestination(context.Background(), "artifact.pdf", nil) | |
| 36 | 38 | ||
| 37 | 39 | require.NoError(t, err) | |
| 38 | - | assert.Equal(t, "/new/path/artifact.pdf", output.DestinationPath) | |
| 40 | + | assert.Equal(t, filepath.Join(newPath, "artifact.pdf"), output.DestinationPath) | |
| 39 | 41 | } | |
| 40 | 42 | ||
| 41 | 43 | func TestURIResponseAdapter(t *testing.T) { | |
| @@ -2,6 +2,7 @@ package webkit | |||||
| 2 | 2 | ||||
| 3 | import ( | 3 | import ( | ||
| 4 | "context" | 4 | "context" | ||
| 5 | + | "path/filepath" | |||
| 5 | "testing" | 6 | "testing" | ||
| 6 | 7 | ||||
| 7 | "github.com/bnema/dumber/internal/application/usecase" | 8 | "github.com/bnema/dumber/internal/application/usecase" | ||
| @@ -30,12 +31,13 @@ func TestDownloadHandler_SetDownloadPath(t *testing.T) { | |||||
| 30 | prepareUC := usecase.NewPrepareDownloadUseCase(nil) | 31 | prepareUC := usecase.NewPrepareDownloadUseCase(nil) | ||
| 31 | handler := NewDownloadHandler("/initial/path", nil, prepareUC) | 32 | handler := NewDownloadHandler("/initial/path", nil, prepareUC) | ||
| 32 | 33 | ||||
| 33 | - | handler.SetDownloadPath("/new/path") | 34 | + | newPath := t.TempDir() |
| 35 | + | handler.SetDownloadPath(newPath) | |||
| 34 | 36 | ||||
| 35 | output, err := handler.runtime.ResolveDestination(context.Background(), "artifact.pdf", nil) | 37 | output, err := handler.runtime.ResolveDestination(context.Background(), "artifact.pdf", nil) | ||
| 36 | 38 | ||||
| 37 | require.NoError(t, err) | 39 | require.NoError(t, err) | ||
| 38 | - | assert.Equal(t, "/new/path/artifact.pdf", output.DestinationPath) | 40 | + | assert.Equal(t, filepath.Join(newPath, "artifact.pdf"), output.DestinationPath) |
| 39 | } | 41 | } | ||
| 40 | 42 | ||||
| 41 | func TestURIResponseAdapter(t *testing.T) { | 43 | func TestURIResponseAdapter(t *testing.T) { | ||