MCPcopy Index your code
hub / github.com/docker/cli / TestVolumeCreateClusterOpts

Function TestVolumeCreateClusterOpts

cli/command/volume/create_test.go:193–265  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

191}
192
193func TestVolumeCreateClusterOpts(t *testing.T) {
194 expectedOptions := client.VolumeCreateOptions{
195 Name: "name",
196 Driver: "csi",
197 DriverOpts: map[string]string{},
198 Labels: map[string]string{},
199 ClusterVolumeSpec: &volume.ClusterVolumeSpec{
200 Group: "gronp",
201 AccessMode: &volume.AccessMode{
202 Scope: volume.ScopeMultiNode,
203 Sharing: volume.SharingOneWriter,
204 // TODO(dperny): support mount options
205 MountVolume: &volume.TypeMount{},
206 },
207 // TODO(dperny): topology requirements
208 CapacityRange: &volume.CapacityRange{
209 RequiredBytes: 1234,
210 LimitBytes: 567890,
211 },
212 Secrets: []volume.Secret{
213 {Key: "key1", Secret: "secret1"},
214 {Key: "key2", Secret: "secret2"},
215 },
216 Availability: volume.AvailabilityActive,
217 AccessibilityRequirements: &volume.TopologyRequirement{
218 Requisite: []volume.Topology{
219 {Segments: map[string]string{"region": "R1", "zone": "Z1"}},
220 {Segments: map[string]string{"region": "R1", "zone": "Z2"}},
221 {Segments: map[string]string{"region": "R1", "zone": "Z3"}},
222 },
223 Preferred: []volume.Topology{
224 {Segments: map[string]string{"region": "R1", "zone": "Z2"}},
225 {Segments: map[string]string{"region": "R1", "zone": "Z3"}},
226 },
227 },
228 },
229 }
230
231 cli := test.NewFakeCli(&fakeClient{
232 volumeCreateFunc: func(options client.VolumeCreateOptions) (client.VolumeCreateResult, error) {
233 sort.SliceStable(options.ClusterVolumeSpec.Secrets, func(i, j int) bool {
234 return options.ClusterVolumeSpec.Secrets[i].Key < options.ClusterVolumeSpec.Secrets[j].Key
235 })
236 assert.DeepEqual(t, options, expectedOptions)
237 return client.VolumeCreateResult{}, nil
238 },
239 })
240
241 cmd := newCreateCommand(cli)
242 cmd.SetOut(io.Discard)
243 cmd.SetErr(io.Discard)
244 cmd.SetArgs([]string{"name"})
245 assert.Check(t, cmd.Flags().Set("driver", "csi"))
246 assert.Check(t, cmd.Flags().Set("group", "gronp"))
247 assert.Check(t, cmd.Flags().Set("scope", "multi"))
248 assert.Check(t, cmd.Flags().Set("sharing", "onewriter"))
249 assert.Check(t, cmd.Flags().Set("type", "mount"))
250 assert.Check(t, cmd.Flags().Set("sharing", "onewriter"))

Callers

nothing calls this directly

Calls 5

SetArgsMethod · 0.80
newCreateCommandFunction · 0.70
SetOutMethod · 0.45
SetErrMethod · 0.45
SetMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…