-
Notifications
You must be signed in to change notification settings - Fork 244
/
Copy pathioshim_windows.go
50 lines (40 loc) · 1.12 KB
/
ioshim_windows.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
package common
import (
"testing"
"github.com/Azure/azure-container-networking/network/hnswrapper"
testutils "github.com/Azure/azure-container-networking/test/utils"
"github.com/Microsoft/hcsshim/hcn"
utilexec "k8s.io/utils/exec"
)
const FakeHNSNetworkID = "1234"
type IOShim struct {
Exec utilexec.Interface
Hns hnswrapper.HnsV2WrapperInterface
}
func NewIOShim() *IOShim {
return &IOShim{
Exec: utilexec.New(),
Hns: &hnswrapper.Hnsv2wrapper{},
}
}
func NewMockIOShim(calls []testutils.TestCmd) *IOShim {
hns := hnswrapper.NewHnsv2wrapperFake()
network := &hcn.HostComputeNetwork{
Id: FakeHNSNetworkID,
Name: "azure",
}
// CreateNetwork will never return an error
_, _ = hns.CreateNetwork(network)
return &IOShim{
Exec: testutils.GetFakeExecWithScripts(calls),
Hns: hns,
}
}
func NewMockIOShimWithFakeHNS(hns *hnswrapper.Hnsv2wrapperFake) *IOShim {
return &IOShim{
Exec: testutils.GetFakeExecWithScripts([]testutils.TestCmd{}),
Hns: hns,
}
}
// VerifyCalls is used for Unit Testing of linux. In windows this is no-op
func (ioshim *IOShim) VerifyCalls(_ *testing.T, _ []testutils.TestCmd) {}