test: cover mobile transfer and selected archives
This commit is contained in:
@@ -138,6 +138,25 @@ func TestUserManagementAndPrivateHome(t *testing.T) {
|
||||
if rr.Code != http.StatusOK || !strings.Contains(rr.Body.String(), "我的空间") || !strings.Contains(rr.Body.String(), "public") {
|
||||
t.Fatalf("accessible roots: %d %s", rr.Code, rr.Body.String())
|
||||
}
|
||||
|
||||
req = httptest.NewRequest(http.MethodGet, "/chfs/qrcode?url=https%3A%2F%2Fexample.com", nil)
|
||||
req.AddCookie(&http.Cookie{Name: "JWT", Value: token})
|
||||
rr = httptest.NewRecorder()
|
||||
h.ServeHTTP(rr, req)
|
||||
if rr.Code != http.StatusOK || rr.Header().Get("Content-Type") != "image/png" || len(rr.Body.Bytes()) < 100 {
|
||||
t.Fatalf("qrcode: %d %q %d", rr.Code, rr.Header().Get("Content-Type"), len(rr.Body.Bytes()))
|
||||
}
|
||||
|
||||
if err := os.WriteFile(filepath.Join(root, "public", "second.txt"), []byte("two"), 0644); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
req = httptest.NewRequest(http.MethodGet, "/chfs/downloadzip?path=public%2Freadme.txt&path=public%2Fsecond.txt", nil)
|
||||
req.AddCookie(&http.Cookie{Name: "JWT", Value: token})
|
||||
rr = httptest.NewRecorder()
|
||||
h.ServeHTTP(rr, req)
|
||||
if rr.Code != http.StatusOK || rr.Header().Get("Content-Type") != "application/zip" || len(rr.Body.Bytes()) < 50 {
|
||||
t.Fatalf("selected zip: %d %q %d", rr.Code, rr.Header().Get("Content-Type"), len(rr.Body.Bytes()))
|
||||
}
|
||||
var saved []map[string]any
|
||||
data, err := os.ReadFile(usersFile)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user