mirror of
https://github.com/truewhile/MeBox.git
synced 2026-10-03 12:26:36 +08:00
refactor: split modules and harden scraping workflows
This commit is contained in:
@@ -80,6 +80,22 @@ func TestImageProxyServesPosterUnderLibraryRoot(t *testing.T) {
|
||||
if got := rec.Body.Bytes(); string(got) != string(realPoster) {
|
||||
t.Fatalf("served %q, want real poster bytes", string(got))
|
||||
}
|
||||
etag := rec.Header().Get("ETag")
|
||||
if etag == "" {
|
||||
t.Fatal("expected static image ETag")
|
||||
}
|
||||
req := httptest.NewRequest(http.MethodGet, "/api/img", nil)
|
||||
req.Header.Set("If-None-Match", etag)
|
||||
rec = httptest.NewRecorder()
|
||||
if err := proxy.Serve(t.Context(), rec, req, posterPath); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if rec.Code != http.StatusNotModified {
|
||||
t.Fatalf("conditional status = %d, want 304", rec.Code)
|
||||
}
|
||||
if rec.Body.Len() != 0 {
|
||||
t.Fatalf("conditional body length = %d, want 0", rec.Body.Len())
|
||||
}
|
||||
}
|
||||
|
||||
func TestImageProxyCachesFailedRemoteImageFetch(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user