forked from moby/swarmkit
/
plugin_test.go
57 lines (43 loc) · 1.18 KB
/
plugin_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
46
47
48
49
50
51
52
53
54
55
56
57
package csi
import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"context"
"github.com/container-storage-interface/spec/lib/go/csi"
"github.com/docker/swarmkit/api"
)
const driverName = "testdriver"
// newPluginFromClients creates a new node plugin using the provided CSI RPC
// clients.
func newPluginFromClients(name string, nodeClient csi.NodeClient, nodeId string) *NodePlugin {
return &NodePlugin{
Name: name,
NodeClient: nodeClient,
NodeID: nodeId,
}
}
var _ = Describe("Plugin Node", func() {
var (
nodePlugin *NodePlugin
nodeClient *fakeNodeClient
nodeInfo *api.NodeCSIInfo
err error
)
BeforeEach(func() {
nodeClient = newFakeNodeClient()
nodePlugin = newPluginFromClients(driverName, nodeClient, "1")
})
JustBeforeEach(func() {
nodeInfo, err = nodePlugin.NodeGetInfo(context.Background())
})
It("should return a correct NodeCSIInfo object", func() {
Expect(nodeInfo).ToNot(BeNil())
Expect(nodeInfo.NodeID).To(Equal("nodeid1"))
})
It("should not return an error", func() {
Expect(err).ToNot(HaveOccurred())
})
It("should create correct node info requests", func() {
Expect(nodeClient.NodeGetInfo).To(HaveLen(1))
})
})