test(cef): use temp dir for download handler lifecycle
- commit
- 44cfca44604f6443669628ec99fffb9676630d9d
- author
- brice · · 2026-04-20 05:57 UTC
- parent
- b04eecd
- signature
- GPG Verified
CD88F9E564E0102646FB6077A1A07C7C7C3E349D· arch-gpg Verified for the committer email
1 file · +4 -2
M internal/infrastructure/cef/download_handler_test.go +4 -2
| @@ -3,6 +3,7 @@ package cef | |||
| 3 | 3 | import ( | |
| 4 | 4 | "context" | |
| 5 | 5 | "fmt" | |
| 6 | + | "path/filepath" | |
| 6 | 7 | "testing" | |
| 7 | 8 | ||
| 8 | 9 | purecef "github.com/bnema/purego-cef/cef" | |
| @@ -72,7 +73,8 @@ func TestCEFDownloadHandlerLifecycle(t *testing.T) { | |||
| 72 | 73 | ctx := context.Background() | |
| 73 | 74 | preparer := usecase.NewPrepareDownloadUseCase(nil) | |
| 74 | 75 | events := &captureDownloadEvents{} | |
| 75 | - | handler := newDownloadHandler("/tmp/downloads", events, preparer) | |
| 76 | + | downloadDir := t.TempDir() | |
| 77 | + | handler := newDownloadHandler(downloadDir, events, preparer) | |
| 76 | 78 | callback := &stubBeforeDownloadCallback{} | |
| 77 | 79 | ||
| 78 | 80 | item := stubDownloadItem{ | |
| @@ -85,7 +87,7 @@ func TestCEFDownloadHandlerLifecycle(t *testing.T) { | |||
| 85 | 87 | ok := handler.onBeforeDownload(ctx, nil, item, item.suggested, callback) | |
| 86 | 88 | ||
| 87 | 89 | require.True(t, ok) | |
| 88 | - | require.Equal(t, "/tmp/downloads/image.iso", callback.path) | |
| 90 | + | require.Equal(t, filepath.Join(downloadDir, "image.iso"), callback.path) | |
| 89 | 91 | require.Len(t, events.events, 1) | |
| 90 | 92 | require.Equal(t, port.DownloadEventStarted, events.events[0].Type) | |
| 91 | 93 | ||
| @@ -3,6 +3,7 @@ package cef | |||||
| 3 | import ( | 3 | import ( | ||
| 4 | "context" | 4 | "context" | ||
| 5 | "fmt" | 5 | "fmt" | ||
| 6 | + | "path/filepath" | |||
| 6 | "testing" | 7 | "testing" | ||
| 7 | 8 | ||||
| 8 | purecef "github.com/bnema/purego-cef/cef" | 9 | purecef "github.com/bnema/purego-cef/cef" | ||
| @@ -72,7 +73,8 @@ func TestCEFDownloadHandlerLifecycle(t *testing.T) { | |||||
| 72 | ctx := context.Background() | 73 | ctx := context.Background() | ||
| 73 | preparer := usecase.NewPrepareDownloadUseCase(nil) | 74 | preparer := usecase.NewPrepareDownloadUseCase(nil) | ||
| 74 | events := &captureDownloadEvents{} | 75 | events := &captureDownloadEvents{} | ||
| 75 | - | handler := newDownloadHandler("/tmp/downloads", events, preparer) | 76 | + | downloadDir := t.TempDir() |
| 77 | + | handler := newDownloadHandler(downloadDir, events, preparer) | |||
| 76 | callback := &stubBeforeDownloadCallback{} | 78 | callback := &stubBeforeDownloadCallback{} | ||
| 77 | 79 | ||||
| 78 | item := stubDownloadItem{ | 80 | item := stubDownloadItem{ | ||
| @@ -85,7 +87,7 @@ func TestCEFDownloadHandlerLifecycle(t *testing.T) { | |||||
| 85 | ok := handler.onBeforeDownload(ctx, nil, item, item.suggested, callback) | 87 | ok := handler.onBeforeDownload(ctx, nil, item, item.suggested, callback) | ||
| 86 | 88 | ||||
| 87 | require.True(t, ok) | 89 | require.True(t, ok) | ||
| 88 | - | require.Equal(t, "/tmp/downloads/image.iso", callback.path) | 90 | + | require.Equal(t, filepath.Join(downloadDir, "image.iso"), callback.path) |
| 89 | require.Len(t, events.events, 1) | 91 | require.Len(t, events.events, 1) | ||
| 90 | require.Equal(t, port.DownloadEventStarted, events.events[0].Type) | 92 | require.Equal(t, port.DownloadEventStarted, events.events[0].Type) | ||
| 91 | 93 | ||||