forked from xmidt-org/scytale
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mocks_test.go
45 lines (35 loc) · 1021 Bytes
/
mocks_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
// SPDX-FileCopyrightText: 2019 Comcast Cable Communications Management, LLC
// SPDX-License-Identifier: Apache-2.0
package main
import (
"context"
"net/http"
"net/http/httptest"
"github.com/stretchr/testify/mock"
"github.com/xmidt-org/wrp-go/v3"
"github.com/xmidt-org/wrp-go/v3/wrphttp"
)
type mockWRPAccessAuthority struct {
mock.Mock
}
func (m *mockWRPAccessAuthority) authorizeWRP(ctx context.Context, message *wrp.Message) (bool, error) {
arguments := m.Called(ctx, message)
return arguments.Bool(0), arguments.Error(1)
}
type testWRPResponseWriter struct {
http.ResponseWriter
}
func (t *testWRPResponseWriter) WriteWRP(i *wrphttp.Entity) (int, error) {
return 0, nil
}
func (t *testWRPResponseWriter) WriteWRPBytes(_ wrp.Format, _ []byte) (int, error) {
return 0, nil
}
func (t *testWRPResponseWriter) WRPFormat() wrp.Format {
return wrp.Msgpack
}
func newTestWRPResponseWriter(w *httptest.ResponseRecorder) *testWRPResponseWriter {
return &testWRPResponseWriter{
ResponseWriter: w,
}
}