Adding functionality to get & delete incoming webhooks (#5648)

Этот коммит содержится в:
Poornima
2017-03-12 04:10:56 +05:30
коммит произвёл enahum
родитель 11f1859de1
Коммит 482a0fb5fc
8 изменённых файлов: 269 добавлений и 0 удалений

Просмотреть файл

@@ -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 {

Просмотреть файл

@@ -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) {