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

Function TestMountOptErrors

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

Source from the content-addressed store, hash-verified

106}
107
108func TestMountOptErrors(t *testing.T) {
109 tests := []struct {
110 doc, value, expErr string
111 }{
112 {
113 doc: "empty value",
114 expErr: "value is empty",
115 },
116 {
117 doc: "invalid key=value",
118 value: "type=volume,target=/foo,bogus=foo",
119 expErr: "unknown option 'bogus' in 'bogus=foo'",
120 },
121 {
122 doc: "invalid key with leading whitespace",
123 value: "type=volume, src=/foo,target=/foo",
124 expErr: "invalid option 'src' in ' src=/foo': option should not have whitespace",
125 },
126 {
127 doc: "invalid key with trailing whitespace",
128 value: "type=volume,src =/foo,target=/foo",
129 expErr: "invalid option 'src' in 'src =/foo': option should not have whitespace",
130 },
131 {
132 doc: "invalid value is empty",
133 value: "type=volume,src=,target=/foo",
134 expErr: "invalid value for 'src': value is empty",
135 },
136 {
137 doc: "invalid value with leading whitespace",
138 value: "type=volume,src= /foo,target=/foo",
139 expErr: "invalid value for 'src' in 'src= /foo': value should not have whitespace",
140 },
141 {
142 doc: "invalid value with trailing whitespace",
143 value: "type=volume,src=/foo ,target=/foo",
144 expErr: "invalid value for 'src' in 'src=/foo ': value should not have whitespace",
145 },
146 {
147 doc: "missing value",
148 value: "type=volume,target=/foo,bogus",
149 expErr: "invalid field 'bogus' must be a key=value pair",
150 },
151 {
152 doc: "invalid tmpfs-size",
153 value: "type=tmpfs,target=/foo,tmpfs-size=foo",
154 expErr: "invalid value for tmpfs-size: foo",
155 },
156 {
157 doc: "invalid tmpfs-mode",
158 value: "type=tmpfs,target=/foo,tmpfs-mode=foo",
159 expErr: "invalid value for tmpfs-mode: foo",
160 },
161 {
162 doc: "mixed bind and volume",
163 value: "type=volume,target=/foo,source=/foo,bind-propagation=rprivate",
164 expErr: "cannot mix 'bind-*' options with mount type 'volume'",
165 },

Callers

nothing calls this directly

Calls 2

SetMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…