github.com/Prakhar-Agarwal-byte/moby@v0.0.0-20231027092010-a14e3e8ab87e/daemon/cluster/convert/node_test.go (about) 1 package convert 2 3 import ( 4 "testing" 5 6 types "github.com/Prakhar-Agarwal-byte/moby/api/types/swarm" 7 swarmapi "github.com/moby/swarmkit/v2/api" 8 "gotest.tools/v3/assert" 9 ) 10 11 // TestNodeCSIInfoFromGRPC tests that conversion of the NodeCSIInfo from the 12 // gRPC to the Docker types is correct. 13 func TestNodeCSIInfoFromGRPC(t *testing.T) { 14 node := &swarmapi.Node{ 15 ID: "someID", 16 Description: &swarmapi.NodeDescription{ 17 CSIInfo: []*swarmapi.NodeCSIInfo{ 18 { 19 PluginName: "plugin1", 20 NodeID: "p1n1", 21 MaxVolumesPerNode: 1, 22 }, 23 { 24 PluginName: "plugin2", 25 NodeID: "p2n1", 26 MaxVolumesPerNode: 2, 27 AccessibleTopology: &swarmapi.Topology{ 28 Segments: map[string]string{ 29 "a": "1", 30 "b": "2", 31 }, 32 }, 33 }, 34 }, 35 }, 36 } 37 38 expected := []types.NodeCSIInfo{ 39 { 40 PluginName: "plugin1", 41 NodeID: "p1n1", 42 MaxVolumesPerNode: 1, 43 }, 44 { 45 PluginName: "plugin2", 46 NodeID: "p2n1", 47 MaxVolumesPerNode: 2, 48 AccessibleTopology: &types.Topology{ 49 Segments: map[string]string{ 50 "a": "1", 51 "b": "2", 52 }, 53 }, 54 }, 55 } 56 57 actual := NodeFromGRPC(*node) 58 59 assert.DeepEqual(t, actual.Description.CSIInfo, expected) 60 }