Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1diff --git a/server_test.go b/server_test.go 2index fc225ce..2df3608 100644 3--- a/server_test.go 4+++ b/server_test.go 5@@ -446,63 +446,6 @@ func TestPostJSONUpload(t *testing.T) { 6 } 7 } 8 9-func TestPostJSONUploadMaxExpiry(t *testing.T) { 10- mux := setup() 11- Config.maxExpiry = 300 12- 13- // include 0 to test edge case 14- // https://github.com/andreimarcu/linx-server/issues/111 15- testExpiries := []string{"86400", "-150", "0"} 16- for _, expiry := range testExpiries { 17- w := httptest.NewRecorder() 18- 19- filename := generateBarename() + ".txt" 20- 21- var b bytes.Buffer 22- mw := multipart.NewWriter(&b) 23- fw, err := mw.CreateFormFile("file", filename) 24- if err != nil { 25- t.Fatal(err) 26- } 27- 28- fw.Write([]byte("File content")) 29- mw.Close() 30- 31- req, err := http.NewRequest("POST", "/upload/", &b) 32- req.Header.Set("Content-Type", mw.FormDataContentType()) 33- req.Header.Set("Accept", "application/json") 34- req.Header.Set("Linx-Expiry", expiry) 35- if err != nil { 36- t.Fatal(err) 37- } 38- 39- mux.ServeHTTP(w, req) 40- 41- if w.Code != 200 { 42- t.Log(w.Body.String()) 43- t.Fatalf("Status code is not 200, but %d", w.Code) 44- } 45- 46- var myjson RespOkJSON 47- err = json.Unmarshal([]byte(w.Body.String()), &myjson) 48- if err != nil { 49- t.Fatal(err) 50- } 51- 52- myExp, err := strconv.ParseInt(myjson.Expiry, 10, 64) 53- if err != nil { 54- t.Fatal(err) 55- } 56- 57- expected := time.Now().Add(time.Duration(Config.maxExpiry) * time.Second).Unix() 58- if myExp != expected { 59- t.Fatalf("File expiry is not %d but %s", expected, myjson.Expiry) 60- } 61- } 62- 63- Config.maxExpiry = 0 64-} 65- 66 func TestPostExpiresJSONUpload(t *testing.T) { 67 mux := setup() 68 w := httptest.NewRecorder() 69@@ -1301,5 +1244,4 @@ func TestPutAndGetCLI(t *testing.T) { 70 if !strings.HasPrefix(contentType, "text/plain") { 71 t.Fatalf("Didn't receive file directly but %s", contentType) 72 } 73- 74 }