From 3922ee968ab8c07ca90f60dffd2b816500865ffb Mon Sep 17 00:00:00 2001 From: Umputun Date: Wed, 10 Jan 2018 03:20:14 -0600 Subject: [PATCH] restore missed delete --- app/rest/server.go | 1 + app/rest/server_test.go | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/app/rest/server.go b/app/rest/server.go index 444e8dab..ee3647d7 100644 --- a/app/rest/server.go +++ b/app/rest/server.go @@ -91,6 +91,7 @@ func (s *Server) Run(port int) { rapi.With(auth.Auth(s.SessionStore, s.Admins, maybeDevMode(auth.Full))).Group(func(rauth chi.Router) { rauth.Post("/comment", s.createCommentCtrl) rauth.Put("/comment/{id}", s.updateCommentCtrl) + rauth.Delete("/comment/{id}", s.deleteCommentCtrl) rauth.Get("/user", s.userInfoCtrl) rauth.Put("/vote/{id}", s.voteCtrl) diff --git a/app/rest/server_test.go b/app/rest/server_test.go index 88063145..bb0df721 100644 --- a/app/rest/server_test.go +++ b/app/rest/server_test.go @@ -231,13 +231,14 @@ func TestServer_Delete(t *testing.T) { client := http.Client{} req, err := http.NewRequest(http.MethodDelete, - fmt.Sprintf("http://127.0.0.1:%d/api/v1/comment/%s?site=radio-t&url=https://radio-t.com/blah1", port, id1), + fmt.Sprintf("http://127.0.0.1:%d/api/v1/comment/%s?site=radio-t&url=https://radio-t.com/blah", port, id1), nil) assert.Nil(t, err) - _, err = client.Do(req) + resp, err := client.Do(req) assert.Nil(t, err) + assert.Equal(t, 200, resp.StatusCode) - _, code := get(t, fmt.Sprintf("http://127.0.0.1:%d/api/v1/id/%s?site=radio-t&url=https://radio-t.com/blah1", port, id1)) + _, code := get(t, fmt.Sprintf("http://127.0.0.1:%d/api/v1/id/%s?site=radio-t&url=https://radio-t.com/blah", port, id1)) assert.Equal(t, 400, code) }