diff options
author | Poornima <mpoornima@users.noreply.github.com> | 2017-03-12 04:10:56 +0530 |
---|---|---|
committer | enahum <nahumhbl@gmail.com> | 2017-03-11 19:40:56 -0300 |
commit | 482a0fb5fc248b1ec61db35299dc3e6d963ad5ab (patch) | |
tree | 1f957f78b3a053366ca20fbcff8b274ea5eac4a0 /store | |
parent | 11f1859de12be22726a93bb0fd201f3d692022a0 (diff) | |
download | chat-482a0fb5fc248b1ec61db35299dc3e6d963ad5ab.tar.gz chat-482a0fb5fc248b1ec61db35299dc3e6d963ad5ab.tar.bz2 chat-482a0fb5fc248b1ec61db35299dc3e6d963ad5ab.zip |
Adding functionality to get & delete incoming webhooks (#5648)
Diffstat (limited to 'store')
-rw-r--r-- | store/sql_webhook_store.go | 5 | ||||
-rw-r--r-- | store/sql_webhook_store_test.go | 6 |
2 files changed, 11 insertions, 0 deletions
diff --git a/store/sql_webhook_store.go b/store/sql_webhook_store.go index 355678064..e0e6562bf 100644 --- a/store/sql_webhook_store.go +++ b/store/sql_webhook_store.go @@ -6,6 +6,8 @@ package store import ( "net/http" + "database/sql" + "github.com/mattermost/platform/einterfaces" "github.com/mattermost/platform/model" "github.com/mattermost/platform/utils" @@ -155,6 +157,9 @@ func (s SqlWebhookStore) GetIncoming(id string, allowFromCache bool) StoreChanne if err := s.GetReplica().SelectOne(&webhook, "SELECT * FROM IncomingWebhooks WHERE Id = :Id AND DeleteAt = 0", map[string]interface{}{"Id": id}); err != nil { result.Err = model.NewLocAppError("SqlWebhookStore.GetIncoming", "store.sql_webhooks.get_incoming.app_error", nil, "id="+id+", err="+err.Error()) + if err == sql.ErrNoRows { + result.Err.StatusCode = http.StatusNotFound + } } if result.Err == nil { diff --git a/store/sql_webhook_store_test.go b/store/sql_webhook_store_test.go index e1aaad1b7..20bb8c151 100644 --- a/store/sql_webhook_store_test.go +++ b/store/sql_webhook_store_test.go @@ -6,6 +6,8 @@ package store import ( "testing" + "net/http" + "github.com/mattermost/platform/model" ) @@ -72,6 +74,10 @@ func TestWebhookStoreGetIncoming(t *testing.T) { if err := (<-store.Webhook().GetIncoming("123", true)).Err; err == nil { t.Fatal("Missing id should have failed") } + + if err := (<-store.Webhook().GetIncoming("123", true)).Err; err.StatusCode != http.StatusNotFound { + t.Fatal("Should have set the status as not found for missing id") + } } func TestWebhookStoreGetIncomingList(t *testing.T) { |