MCPcopy Create free account
hub / github.com/docker/cli / TestVolumeCreateCluster

Function TestVolumeCreateCluster

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

Source from the content-addressed store, hash-verified

155}
156
157func TestVolumeCreateCluster(t *testing.T) {
158 cli := test.NewFakeCli(&fakeClient{
159 volumeCreateFunc: func(options client.VolumeCreateOptions) (client.VolumeCreateResult, error) {
160 if options.Driver == "csi" && options.ClusterVolumeSpec == nil {
161 return client.VolumeCreateResult{}, errors.New("expected ClusterVolumeSpec, but none present")
162 }
163 if options.Driver == "notcsi" && options.ClusterVolumeSpec != nil {
164 return client.VolumeCreateResult{}, errors.New("expected no ClusterVolumeSpec, but present")
165 }
166 return client.VolumeCreateResult{}, nil
167 },
168 })
169
170 t.Run("csi-volume", func(t *testing.T) {
171 cmd := newCreateCommand(cli)
172 cmd.SetOut(io.Discard)
173 cmd.SetErr(io.Discard)
174 assert.Check(t, cmd.Flags().Set("type", "block"))
175 assert.Check(t, cmd.Flags().Set("group", "gronp"))
176 assert.Check(t, cmd.Flags().Set("driver", "csi"))
177 cmd.SetArgs([]string{"my-csi-volume"})
178
179 assert.NilError(t, cmd.Execute())
180 })
181
182 t.Run("non-csi-volume", func(t *testing.T) {
183 cmd := newCreateCommand(cli)
184 cmd.SetOut(io.Discard)
185 cmd.SetErr(io.Discard)
186 assert.Check(t, cmd.Flags().Set("driver", "notcsi"))
187 cmd.SetArgs([]string{"my-non-csi-volume"})
188
189 assert.NilError(t, cmd.Execute())
190 })
191}
192
193func TestVolumeCreateClusterOpts(t *testing.T) {
194 expectedOptions := client.VolumeCreateOptions{

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…