forked from xmidt-org/ancla
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathendpoint_test.go
39 lines (33 loc) · 890 Bytes
/
endpoint_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package ancla
import (
"context"
"errors"
"testing"
"github.com/stretchr/testify/assert"
)
func TestNewAddWebhookEndpoint(t *testing.T) {
assert := assert.New(t)
m := new(mockService)
endpoint := newAddWebhookEndpoint(m)
input := &addWebhookRequest{
owner: "owner-val",
webhook: Webhook{},
}
errFake := errors.New("failed")
m.On("Add", context.TODO(), "owner-val", input.webhook).Return(errFake)
resp, err := endpoint(context.Background(), input)
assert.Nil(resp)
assert.Equal(errFake, err)
m.AssertExpectations(t)
}
func TestGetAllWebhooksEndpoint(t *testing.T) {
assert := assert.New(t)
m := new(mockService)
endpoint := newGetAllWebhooksEndpoint(m)
respFake := []Webhook{}
m.On("AllWebhooks", context.TODO()).Return(respFake, nil)
resp, err := endpoint(context.Background(), nil)
assert.Nil(err)
assert.Equal(respFake, resp)
m.AssertExpectations(t)
}