Implement GET and POST /hooks/outgoing endpoints for APIv4 (#5645)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
3ebfb36953
Коммит
19c67d7fe3
@@ -240,6 +240,59 @@ func TestWebhookStoreGetOutgoing(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestWebhookStoreGetOutgoingList(t *testing.T) {
|
||||
Setup()
|
||||
|
||||
o1 := &model.OutgoingWebhook{}
|
||||
o1.ChannelId = model.NewId()
|
||||
o1.CreatorId = model.NewId()
|
||||
o1.TeamId = model.NewId()
|
||||
o1.CallbackURLs = []string{"http://nowhere.com/"}
|
||||
|
||||
o1 = (<-store.Webhook().SaveOutgoing(o1)).Data.(*model.OutgoingWebhook)
|
||||
|
||||
o2 := &model.OutgoingWebhook{}
|
||||
o2.ChannelId = model.NewId()
|
||||
o2.CreatorId = model.NewId()
|
||||
o2.TeamId = model.NewId()
|
||||
o2.CallbackURLs = []string{"http://nowhere.com/"}
|
||||
|
||||
o2 = (<-store.Webhook().SaveOutgoing(o2)).Data.(*model.OutgoingWebhook)
|
||||
|
||||
if r1 := <-store.Webhook().GetOutgoingList(0, 1000); r1.Err != nil {
|
||||
t.Fatal(r1.Err)
|
||||
} else {
|
||||
hooks := r1.Data.([]*model.OutgoingWebhook)
|
||||
found1 := false
|
||||
found2 := false
|
||||
|
||||
for _, hook := range hooks {
|
||||
if hook.CreateAt != o1.CreateAt {
|
||||
found1 = true
|
||||
}
|
||||
|
||||
if hook.CreateAt != o2.CreateAt {
|
||||
found2 = true
|
||||
}
|
||||
}
|
||||
|
||||
if !found1 {
|
||||
t.Fatal("missing hook1")
|
||||
}
|
||||
if !found2 {
|
||||
t.Fatal("missing hook2")
|
||||
}
|
||||
}
|
||||
|
||||
if result := <-store.Webhook().GetOutgoingList(0, 2); result.Err != nil {
|
||||
t.Fatal(result.Err)
|
||||
} else {
|
||||
if len(result.Data.([]*model.OutgoingWebhook)) != 2 {
|
||||
t.Fatal("wrong number of hooks returned")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestWebhookStoreGetOutgoingByChannel(t *testing.T) {
|
||||
Setup()
|
||||
|
||||
@@ -251,7 +304,7 @@ func TestWebhookStoreGetOutgoingByChannel(t *testing.T) {
|
||||
|
||||
o1 = (<-store.Webhook().SaveOutgoing(o1)).Data.(*model.OutgoingWebhook)
|
||||
|
||||
if r1 := <-store.Webhook().GetOutgoingByChannel(o1.ChannelId); r1.Err != nil {
|
||||
if r1 := <-store.Webhook().GetOutgoingByChannel(o1.ChannelId, 0, 100); r1.Err != nil {
|
||||
t.Fatal(r1.Err)
|
||||
} else {
|
||||
if r1.Data.([]*model.OutgoingWebhook)[0].CreateAt != o1.CreateAt {
|
||||
@@ -259,7 +312,7 @@ func TestWebhookStoreGetOutgoingByChannel(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
if result := <-store.Webhook().GetOutgoingByChannel("123"); result.Err != nil {
|
||||
if result := <-store.Webhook().GetOutgoingByChannel("123", -1, -1); result.Err != nil {
|
||||
t.Fatal(result.Err)
|
||||
} else {
|
||||
if len(result.Data.([]*model.OutgoingWebhook)) != 0 {
|
||||
@@ -279,7 +332,7 @@ func TestWebhookStoreGetOutgoingByTeam(t *testing.T) {
|
||||
|
||||
o1 = (<-store.Webhook().SaveOutgoing(o1)).Data.(*model.OutgoingWebhook)
|
||||
|
||||
if r1 := <-store.Webhook().GetOutgoingByTeam(o1.TeamId); r1.Err != nil {
|
||||
if r1 := <-store.Webhook().GetOutgoingByTeam(o1.TeamId, 0, 100); r1.Err != nil {
|
||||
t.Fatal(r1.Err)
|
||||
} else {
|
||||
if r1.Data.([]*model.OutgoingWebhook)[0].CreateAt != o1.CreateAt {
|
||||
@@ -287,7 +340,7 @@ func TestWebhookStoreGetOutgoingByTeam(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
if result := <-store.Webhook().GetOutgoingByTeam("123"); result.Err != nil {
|
||||
if result := <-store.Webhook().GetOutgoingByTeam("123", -1, -1); result.Err != nil {
|
||||
t.Fatal(result.Err)
|
||||
} else {
|
||||
if len(result.Data.([]*model.OutgoingWebhook)) != 0 {
|
||||
|
||||
Ссылка в новой задаче
Block a user