forked from teddyking/netsetgo
/
fake_bridge_creator.go
128 lines (114 loc) · 3.53 KB
/
fake_bridge_creator.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
// This file was generated by counterfeiter
package configurerfakes
import (
"net"
"sync"
"github.com/teddyking/netsetgo/configurer"
)
type FakeBridgeCreator struct {
CreateStub func(name string, ip net.IP, subnet *net.IPNet) (*net.Interface, error)
createMutex sync.RWMutex
createArgsForCall []struct {
name string
ip net.IP
subnet *net.IPNet
}
createReturns struct {
result1 *net.Interface
result2 error
}
AttachStub func(bridge, hostVeth *net.Interface) error
attachMutex sync.RWMutex
attachArgsForCall []struct {
bridge *net.Interface
hostVeth *net.Interface
}
attachReturns struct {
result1 error
}
invocations map[string][][]interface{}
invocationsMutex sync.RWMutex
}
func (fake *FakeBridgeCreator) Create(name string, ip net.IP, subnet *net.IPNet) (*net.Interface, error) {
fake.createMutex.Lock()
fake.createArgsForCall = append(fake.createArgsForCall, struct {
name string
ip net.IP
subnet *net.IPNet
}{name, ip, subnet})
fake.recordInvocation("Create", []interface{}{name, ip, subnet})
fake.createMutex.Unlock()
if fake.CreateStub != nil {
return fake.CreateStub(name, ip, subnet)
} else {
return fake.createReturns.result1, fake.createReturns.result2
}
}
func (fake *FakeBridgeCreator) CreateCallCount() int {
fake.createMutex.RLock()
defer fake.createMutex.RUnlock()
return len(fake.createArgsForCall)
}
func (fake *FakeBridgeCreator) CreateArgsForCall(i int) (string, net.IP, *net.IPNet) {
fake.createMutex.RLock()
defer fake.createMutex.RUnlock()
return fake.createArgsForCall[i].name, fake.createArgsForCall[i].ip, fake.createArgsForCall[i].subnet
}
func (fake *FakeBridgeCreator) CreateReturns(result1 *net.Interface, result2 error) {
fake.CreateStub = nil
fake.createReturns = struct {
result1 *net.Interface
result2 error
}{result1, result2}
}
func (fake *FakeBridgeCreator) Attach(bridge *net.Interface, hostVeth *net.Interface) error {
fake.attachMutex.Lock()
fake.attachArgsForCall = append(fake.attachArgsForCall, struct {
bridge *net.Interface
hostVeth *net.Interface
}{bridge, hostVeth})
fake.recordInvocation("Attach", []interface{}{bridge, hostVeth})
fake.attachMutex.Unlock()
if fake.AttachStub != nil {
return fake.AttachStub(bridge, hostVeth)
} else {
return fake.attachReturns.result1
}
}
func (fake *FakeBridgeCreator) AttachCallCount() int {
fake.attachMutex.RLock()
defer fake.attachMutex.RUnlock()
return len(fake.attachArgsForCall)
}
func (fake *FakeBridgeCreator) AttachArgsForCall(i int) (*net.Interface, *net.Interface) {
fake.attachMutex.RLock()
defer fake.attachMutex.RUnlock()
return fake.attachArgsForCall[i].bridge, fake.attachArgsForCall[i].hostVeth
}
func (fake *FakeBridgeCreator) AttachReturns(result1 error) {
fake.AttachStub = nil
fake.attachReturns = struct {
result1 error
}{result1}
}
func (fake *FakeBridgeCreator) Invocations() map[string][][]interface{} {
fake.invocationsMutex.RLock()
defer fake.invocationsMutex.RUnlock()
fake.createMutex.RLock()
defer fake.createMutex.RUnlock()
fake.attachMutex.RLock()
defer fake.attachMutex.RUnlock()
return fake.invocations
}
func (fake *FakeBridgeCreator) recordInvocation(key string, args []interface{}) {
fake.invocationsMutex.Lock()
defer fake.invocationsMutex.Unlock()
if fake.invocations == nil {
fake.invocations = map[string][][]interface{}{}
}
if fake.invocations[key] == nil {
fake.invocations[key] = [][]interface{}{}
}
fake.invocations[key] = append(fake.invocations[key], args)
}
var _ configurer.BridgeCreator = new(FakeBridgeCreator)