| 520 | } |
| 521 | |
| 522 | func TestMountOptSetBindRecursive(t *testing.T) { |
| 523 | t.Run("enabled", func(t *testing.T) { |
| 524 | var m MountOpt |
| 525 | assert.NilError(t, m.Set("type=bind,source=/foo,target=/bar,bind-recursive=enabled")) |
| 526 | assert.Check(t, is.DeepEqual([]mount.Mount{ |
| 527 | { |
| 528 | Type: mount.TypeBind, |
| 529 | Source: "/foo", |
| 530 | Target: "/bar", |
| 531 | }, |
| 532 | }, m.Value())) |
| 533 | }) |
| 534 | |
| 535 | t.Run("disabled", func(t *testing.T) { |
| 536 | var m MountOpt |
| 537 | assert.NilError(t, m.Set("type=bind,source=/foo,target=/bar,bind-recursive=disabled")) |
| 538 | assert.Check(t, is.DeepEqual([]mount.Mount{ |
| 539 | { |
| 540 | Type: mount.TypeBind, |
| 541 | Source: "/foo", |
| 542 | Target: "/bar", |
| 543 | BindOptions: &mount.BindOptions{ |
| 544 | NonRecursive: true, |
| 545 | }, |
| 546 | }, |
| 547 | }, m.Value())) |
| 548 | }) |
| 549 | |
| 550 | t.Run("writable", func(t *testing.T) { |
| 551 | var m MountOpt |
| 552 | assert.Error(t, m.Set("type=bind,source=/foo,target=/bar,bind-recursive=writable"), |
| 553 | "option 'bind-recursive=writable' requires 'readonly' to be specified in conjunction") |
| 554 | assert.NilError(t, m.Set("type=bind,source=/foo,target=/bar,bind-recursive=writable,readonly")) |
| 555 | assert.Check(t, is.DeepEqual([]mount.Mount{ |
| 556 | { |
| 557 | Type: mount.TypeBind, |
| 558 | Source: "/foo", |
| 559 | Target: "/bar", |
| 560 | ReadOnly: true, |
| 561 | BindOptions: &mount.BindOptions{ |
| 562 | ReadOnlyNonRecursive: true, |
| 563 | }, |
| 564 | }, |
| 565 | }, m.Value())) |
| 566 | }) |
| 567 | |
| 568 | t.Run("readonly", func(t *testing.T) { |
| 569 | var m MountOpt |
| 570 | assert.Error(t, m.Set("type=bind,source=/foo,target=/bar,bind-recursive=readonly"), |
| 571 | "option 'bind-recursive=readonly' requires 'readonly' to be specified in conjunction") |
| 572 | assert.Error(t, m.Set("type=bind,source=/foo,target=/bar,bind-recursive=readonly,readonly"), |
| 573 | "option 'bind-recursive=readonly' requires 'bind-propagation=rprivate' to be specified in conjunction") |
| 574 | assert.NilError(t, m.Set("type=bind,source=/foo,target=/bar,bind-recursive=readonly,readonly,bind-propagation=rprivate")) |
| 575 | assert.Check(t, is.DeepEqual([]mount.Mount{ |
| 576 | { |
| 577 | Type: mount.TypeBind, |
| 578 | Source: "/foo", |
| 579 | Target: "/bar", |