-
Notifications
You must be signed in to change notification settings - Fork 0
/
client_mock.go
59 lines (47 loc) · 1.33 KB
/
client_mock.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
47
48
49
50
51
52
53
54
55
56
57
58
59
package headscale
import (
"context"
"net/http"
"net/url"
"github.com/stretchr/testify/mock"
)
// MockClient is a mock implementation of the HeadscaleClientInterface.
type MockClient struct {
mock.Mock
}
func NewMockClient() HeadscaleClientInterface {
return &MockClient{}
}
func (m *MockClient) buildURL(pathParts ...any) *url.URL {
args := m.Called(pathParts...)
return args.Get(0).(*url.URL)
}
func (m *MockClient) buildRequest(ctx context.Context, method string, uri *url.URL, opt requestOptions) (*http.Request, error) {
args := m.Called(ctx, method, uri, opt)
return args.Get(0).(*http.Request), args.Error(1)
}
func (m *MockClient) do(ctx context.Context, req *http.Request, v interface{}) error {
args := m.Called(req, v)
return args.Error(0)
}
// Implementing the HeadscaleClientInterface methods
func (m *MockClient) APIKeys() *APIKeyResource {
args := m.Called()
return args.Get(0).(*APIKeyResource)
}
func (m *MockClient) Nodes() *NodeResource {
args := m.Called()
return args.Get(0).(*NodeResource)
}
func (m *MockClient) Policy() *PolicyResource {
args := m.Called()
return args.Get(0).(*PolicyResource)
}
func (m *MockClient) Users() *UserResource {
args := m.Called()
return args.Get(0).(*UserResource)
}
func (m *MockClient) Routes() *RoutesResource {
args := m.Called()
return args.Get(0).(*RoutesResource)
}