Commit 15788281 authored by Lukas Böhm's avatar Lukas Böhm 🎱
Browse files

fix tests

parent f267dfd4
...@@ -156,14 +156,20 @@ func TestDownloadFile(t *testing.T) { ...@@ -156,14 +156,20 @@ func TestDownloadFile(t *testing.T) {
} }
res, _ := http.DefaultClient.Do(req) res, _ := http.DefaultClient.Do(req)
body, _ := ioutil.ReadAll(res.Body) body, _ := ioutil.ReadAll(res.Body)
assert.FileExists(t, filepath.Join("data", shares[0].ID.String(), shares[0].Attachments[0].ID.String())) assert.FileExists(t, filepath.Join(config.mediaDir, "data", shares[0].ID.String(), shares[0].Attachments[0].ID.String()))
expected, _ := ioutil.ReadFile(filepath.Join("data", shares[0].ID.String(), shares[0].Attachments[0].ID.String())) expected, _ := ioutil.ReadFile(filepath.Join(config.mediaDir, "data", shares[0].ID.String(), shares[0].Attachments[0].ID.String()))
assert.EqualValues(t, expected ,body) assert.EqualValues(t, expected ,body)
assert.EqualValues(t, http.StatusOK, res.StatusCode) assert.EqualValues(t, http.StatusOK, res.StatusCode)
}) })
t.Run("unauthorized", func(t *testing.T) {
req, _ := http.NewRequest("GET", fmt.Sprintf("%s/share/%s/attachment/%s", ts.URL, shares[0].ID.String(), shares[0].Attachments[0].ID.String()), nil)
res, _ := http.DefaultClient.Do(req)
assert.EqualValues(t, http.StatusUnauthorized, res.StatusCode)
})
t.Run("not found", func(t *testing.T) { t.Run("not found", func(t *testing.T) {
req, _ := http.NewRequest("GET", fmt.Sprintf("%s/share/%s/attachment/%s", ts.URL, shares[0].ID.String(), "dfvjdfiogbj"), nil) req, _ := http.NewRequest("GET", fmt.Sprintf("%s/share/%s/attachment/%s", ts.URL, shares[0].ID.String(), "0dd9a011-612b-4f33-99c0-bfd687021014"), nil)
res, _ := http.DefaultClient.Do(req) res, _ := http.DefaultClient.Do(req)
assert.EqualValues(t, http.StatusNotFound, res.StatusCode) assert.EqualValues(t, http.StatusNotFound, res.StatusCode)
}) })
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment