generated from xmidt-org/.go-template
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathendpoint_test.go
46 lines (39 loc) · 1.11 KB
/
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
40
41
42
43
44
45
46
// SPDX-FileCopyrightText: 2022 Comcast Cable Communications Management, LLC
// SPDX-License-Identifier: Apache-2.0
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",
internalWebook: InternalWebhook{},
}
errFake := errors.New("failed")
// nolint:typecheck
m.On("Add", context.Background(), "owner-val", input.internalWebook).Return(errFake)
resp, err := endpoint(context.Background(), input)
assert.Nil(resp)
assert.Equal(errFake, err)
// nolint:typecheck
m.AssertExpectations(t)
}
func TestGetAllWebhooksEndpoint(t *testing.T) {
assert := assert.New(t)
m := new(mockService)
endpoint := newGetAllWebhooksEndpoint(m)
respFake := []InternalWebhook{}
// nolint:typecheck
m.On("GetAll", context.Background()).Return(respFake, nil)
resp, err := endpoint(context.Background(), nil)
assert.Nil(err)
assert.Equal(respFake, resp)
// nolint:typecheck
m.AssertExpectations(t)
}