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

Function TestMountOptVolumeNoCopy

opts/mount_test.go:225–267  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

223}
224
225func TestMountOptVolumeNoCopy(t *testing.T) {
226 tests := []struct {
227 value string
228 exp bool
229 expErr string
230 }{
231 {value: "", exp: false},
232 {value: "volume-nocopy", exp: true},
233 {value: "volume-nocopy=", expErr: `invalid value for 'volume-nocopy': value is empty`},
234 {value: "volume-nocopy= true", expErr: `invalid value for 'volume-nocopy' in 'volume-nocopy= true': value should not have whitespace`},
235 {value: "volume-nocopy=no", expErr: `invalid value for 'volume-nocopy': invalid boolean value ("no"): must be one of "true", "1", "false", or "0" (default "true")`},
236 {value: "volume-nocopy=1", exp: true},
237 {value: "volume-nocopy=true", exp: true},
238 {value: "volume-nocopy=0", exp: false},
239 {value: "volume-nocopy=false", exp: false},
240 }
241
242 for _, tc := range tests {
243 name := tc.value
244 if name == "" {
245 name = "not set"
246 }
247 t.Run(name, func(t *testing.T) {
248 val := "type=volume,target=/foo,source=foo"
249 if tc.value != "" {
250 val += "," + tc.value
251 }
252 var m MountOpt
253 err := m.Set(val)
254 if tc.expErr != "" {
255 assert.Error(t, err, tc.expErr)
256 return
257 }
258 assert.NilError(t, err)
259 if tc.value == "" {
260 assert.Check(t, is.Nil(m.values[0].VolumeOptions))
261 } else {
262 assert.Check(t, m.values[0].VolumeOptions != nil)
263 assert.Check(t, is.Equal(m.values[0].VolumeOptions.NoCopy, tc.exp))
264 }
265 })
266 }
267}
268
269func TestMountOptVolumeOptions(t *testing.T) {
270 tests := []struct {

Callers

nothing calls this directly

Calls 2

SetMethod · 0.95
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…