mirror of
https://github.com/idanoo/autobrr
synced 2025-07-23 08:49:13 +00:00
refactor(http): implement bufio (#1604)
* fix: misc http fixes * feat(io): implement bufio around syscalls * peek-a-boo * this can't be right. * you better be wearing a helmet * jesus christ. * refactor(notifications): check err on non-ok status * fix(notifications): add missing name method * refactor(indexer): api clients * fix(indexer): ptp test --------- Co-authored-by: ze0s <ze0s@riseup.net>
This commit is contained in:
parent
d13b421c42
commit
cc0cca9f0d
22 changed files with 465 additions and 304 deletions
|
@ -35,17 +35,26 @@ func Test_client_GetTorrentByID(t *testing.T) {
|
|||
|
||||
id := r.URL.Query().Get("id")
|
||||
var jsonPayload []byte
|
||||
var err error
|
||||
switch id {
|
||||
case "422368":
|
||||
jsonPayload, _ = os.ReadFile("testdata/ggn_get_torrent_by_id.json")
|
||||
jsonPayload, err = os.ReadFile("testdata/ggn_get_torrent_by_id.json")
|
||||
if err != nil {
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(http.StatusOK)
|
||||
break
|
||||
|
||||
case "100002":
|
||||
jsonPayload, _ = os.ReadFile("testdata/ggn_get_torrent_by_id_not_found.json")
|
||||
jsonPayload, err = os.ReadFile("testdata/ggn_get_by_id_not_found.json")
|
||||
if err != nil {
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(http.StatusOK)
|
||||
w.WriteHeader(http.StatusNotFound)
|
||||
break
|
||||
}
|
||||
|
||||
|
@ -102,6 +111,7 @@ func Test_client_GetTorrentByID(t *testing.T) {
|
|||
|
||||
got, err := c.GetTorrentByID(context.Background(), tt.args.torrentID)
|
||||
if tt.wantErr && assert.Error(t, err) {
|
||||
t.Logf("got err: %v", err)
|
||||
assert.Equal(t, tt.wantErr, err)
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue