-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinterface_service_iface.go
More file actions
33 lines (27 loc) · 978 Bytes
/
interface_service_iface.go
File metadata and controls
33 lines (27 loc) · 978 Bytes
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
package truenas
import "context"
// InterfaceServiceAPI defines the interface for network interface operations.
type InterfaceServiceAPI interface {
List(ctx context.Context) ([]NetworkInterface, error)
Get(ctx context.Context, id string) (*NetworkInterface, error)
}
// Compile-time checks.
var _ InterfaceServiceAPI = (*InterfaceService)(nil)
var _ InterfaceServiceAPI = (*MockInterfaceService)(nil)
// MockInterfaceService is a test double for InterfaceServiceAPI.
type MockInterfaceService struct {
ListFunc func(ctx context.Context) ([]NetworkInterface, error)
GetFunc func(ctx context.Context, id string) (*NetworkInterface, error)
}
func (m *MockInterfaceService) List(ctx context.Context) ([]NetworkInterface, error) {
if m.ListFunc != nil {
return m.ListFunc(ctx)
}
return nil, nil
}
func (m *MockInterfaceService) Get(ctx context.Context, id string) (*NetworkInterface, error) {
if m.GetFunc != nil {
return m.GetFunc(ctx, id)
}
return nil, nil
}