more logging

This commit is contained in:
Andre Medeiros 2022-06-30 15:06:03 -04:00
parent 05cb97d412
commit d5affe36c1
3 changed files with 3 additions and 1 deletions

View file

@ -115,6 +115,7 @@ func (a *api) createWatcherHandler(w http.ResponseWriter, r *http.Request) {
if err != nil { if err != nil {
switch err { switch err {
case reddit.ErrSubredditIsPrivate, reddit.ErrSubredditIsQuarantined: case reddit.ErrSubredditIsPrivate, reddit.ErrSubredditIsQuarantined:
err = fmt.Errorf("error watching %s: %w", cwr.Subreddit, err)
a.errorResponse(w, r, 403, err) a.errorResponse(w, r, 403, err)
default: default:
a.errorResponse(w, r, 422, err) a.errorResponse(w, r, 422, err)

View file

@ -170,7 +170,7 @@ func NewSubredditResponse(val *fastjson.Value) interface{} {
data := val.Get("data") data := val.Get("data")
sr.ID = string(data.GetStringBytes("id")) sr.ID = string(data.GetStringBytes("id"))
sr.Name = string(data.GetStringBytes("display_name")) sr.Name = string(data.GetStringBytes("display_name"))
sr.Quarantined = data.GetBool("quarantined") sr.Quarantined = data.GetBool("quarantine")
return sr return sr
} }

View file

@ -136,6 +136,7 @@ func TestSubredditResponseParsing(t *testing.T) {
assert.Equal(t, "t5", s.Kind) assert.Equal(t, "t5", s.Kind)
assert.Equal(t, "2vq0w", s.ID) assert.Equal(t, "2vq0w", s.ID)
assert.Equal(t, "DestinyTheGame", s.Name) assert.Equal(t, "DestinyTheGame", s.Name)
assert.Equal(t, false, s.Quarantined)
} }
func TestUserResponseParsing(t *testing.T) { func TestUserResponseParsing(t *testing.T) {