diff options
author | feistel <6742251-feistel@users.noreply.gitlab.com> | 2021-07-26 18:30:26 +0300 |
---|---|---|
committer | feistel <6742251-feistel@users.noreply.gitlab.com> | 2021-11-08 18:24:14 +0300 |
commit | 77a733b8af393f81c1143ca27324384b1801a090 (patch) | |
tree | c4e17cbfedb872806b3b3c73959806a79d3e3a93 /internal/serving/disk/zip | |
parent | 81e6fdba4fa75b3e882cde818c25a2a76f531de7 (diff) |
refactor: read and use file_sha256 as cache key for zip VFS
Now that the Rails API is serving the archive file_sha256 in the
lookup response, we can move away from using the base URL as the
key to cache the archive.
Changelog: change
Diffstat (limited to 'internal/serving/disk/zip')
-rw-r--r-- | internal/serving/disk/zip/serving_test.go | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/internal/serving/disk/zip/serving_test.go b/internal/serving/disk/zip/serving_test.go index 167c47c3..66e52046 100644 --- a/internal/serving/disk/zip/serving_test.go +++ b/internal/serving/disk/zip/serving_test.go @@ -27,49 +27,58 @@ func TestZip_ServeFileHTTP(t *testing.T) { tests := map[string]struct { vfsPath string + sha256 string path string expectedStatus int expectedBody string }{ "accessing /index.html": { vfsPath: httpURL, + sha256: "d6b318b399cfe9a1c8483e49847ee49a2676d8cfd6df57ec64d971ad03640a75", path: "/index.html", expectedStatus: http.StatusOK, expectedBody: "zip.gitlab.io/project/index.html\n", }, "accessing /index.html from disk": { vfsPath: fileURL, + sha256: "15c5438164ec67bb2225f68d7d7a2e0b608035264e5275b7e3302641aa25a528", path: "/index.html", expectedStatus: http.StatusOK, expectedBody: "zip.gitlab.io/project/index.html\n", }, "accessing /": { vfsPath: httpURL, + sha256: "d6b318b399cfe9a1c8483e49847ee49a2676d8cfd6df57ec64d971ad03640a75", path: "/", expectedStatus: http.StatusOK, expectedBody: "zip.gitlab.io/project/index.html\n", }, "accessing / from disk": { vfsPath: fileURL, + sha256: "15c5438164ec67bb2225f68d7d7a2e0b608035264e5275b7e3302641aa25a528", path: "/", expectedStatus: http.StatusOK, expectedBody: "zip.gitlab.io/project/index.html\n", }, "accessing without /": { vfsPath: httpURL, + sha256: "d6b318b399cfe9a1c8483e49847ee49a2676d8cfd6df57ec64d971ad03640a75", path: "", expectedStatus: http.StatusFound, expectedBody: `<a href="//zip.gitlab.io/zip/">Found</a>.`, }, "accessing without / from disk": { vfsPath: fileURL, + sha256: "15c5438164ec67bb2225f68d7d7a2e0b608035264e5275b7e3302641aa25a528", path: "", expectedStatus: http.StatusFound, expectedBody: `<a href="//zip.gitlab.io/zip/">Found</a>.`, }, "accessing archive that is 404": { vfsPath: testServerURL + "/invalid.zip", - path: "/index.html", + // the sha is needed or we would get a 500 + sha256: "foo", + path: "/index.html", // we expect the status to not be set expectedStatus: 0, }, @@ -111,6 +120,7 @@ func TestZip_ServeFileHTTP(t *testing.T) { LookupPath: &serving.LookupPath{ Prefix: "/zip/", Path: test.vfsPath, + Sha256: test.sha256, }, SubPath: test.path, } |