python312Packages.llama-index: 0.12.9 -> 0.12.9.post1 (#371957)
[NixPkgs.git] / pkgs / by-name / li / linx-server / test.patch
blob7303aecaf8ef7f0fd1bebb43672f394ae9021c62
1 diff --git a/server_test.go b/server_test.go
2 index fc225ce..2df3608 100644
3 --- a/server_test.go
4 +++ b/server_test.go
5 @@ -446,63 +446,6 @@ func TestPostJSONUpload(t *testing.T) {
9 -func TestPostJSONUploadMaxExpiry(t *testing.T) {
10 - mux := setup()
11 - Config.maxExpiry = 300
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()
19 - filename := generateBarename() + ".txt"
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 - }
28 - fw.Write([]byte("File content"))
29 - mw.Close()
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 - }
39 - mux.ServeHTTP(w, req)
41 - if w.Code != 200 {
42 - t.Log(w.Body.String())
43 - t.Fatalf("Status code is not 200, but %d", w.Code)
44 - }
46 - var myjson RespOkJSON
47 - err = json.Unmarshal([]byte(w.Body.String()), &myjson)
48 - if err != nil {
49 - t.Fatal(err)
50 - }
52 - myExp, err := strconv.ParseInt(myjson.Expiry, 10, 64)
53 - if err != nil {
54 - t.Fatal(err)
55 - }
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 - }
63 - Config.maxExpiry = 0
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)