@@ -250,6 +250,32 @@ func TestUpdateMounts(t *testing.T) {
250250 assert .Check (t , is .Equal ("/tokeep" , mounts [1 ].Target ))
251251}
252252
253+ func TestUpdateServiceForcePreservesMountOrder (t * testing.T ) {
254+ flags := newUpdateCommand (nil ).Flags ()
255+ assert .NilError (t , flags .Set ("force" , "true" ))
256+
257+ spec := & swarm.ServiceSpec {
258+ TaskTemplate : swarm.TaskSpec {
259+ ContainerSpec : & swarm.ContainerSpec {
260+ Mounts : []mount.Mount {
261+ {Type : mount .TypeVolume , Source : "z-volume" , Target : "/data/z" },
262+ {Type : mount .TypeVolume , Source : "a-volume" , Target : "/data/a" },
263+ {Type : mount .TypeVolume , Source : "m-volume" , Target : "/data/m" },
264+ },
265+ },
266+ },
267+ }
268+
269+ err := updateService (context .Background (), nil , flags , spec )
270+ assert .NilError (t , err )
271+ assert .Equal (t , spec .TaskTemplate .ForceUpdate , uint64 (1 ))
272+ assert .DeepEqual (t , spec .TaskTemplate .ContainerSpec .Mounts , []mount.Mount {
273+ {Type : mount .TypeVolume , Source : "z-volume" , Target : "/data/z" },
274+ {Type : mount .TypeVolume , Source : "a-volume" , Target : "/data/a" },
275+ {Type : mount .TypeVolume , Source : "m-volume" , Target : "/data/m" },
276+ })
277+ }
278+
253279func TestUpdateMountsWithDuplicateMounts (t * testing.T ) {
254280 flags := newUpdateCommand (nil ).Flags ()
255281 flags .Set ("mount-add" , "type=volume,source=vol4,target=/toadd" )
0 commit comments