aboutsummaryrefslogtreecommitdiffhomepage
path: root/hst/fsbind_test.go
blob: ce904dfab5f5db9fa3b66e7fa57e42e8a9a2dc70 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package hst_test

import (
	"testing"

	"hakurei.app/container"
	"hakurei.app/hst"
)

func TestFSBind(t *testing.T) {
	checkFs(t, []fsTestCase{
		{"nil", (*hst.FSBind)(nil), false, nil, nil, nil, "<invalid>"},

		{"full", &hst.FSBind{
			Dst:      m("/dev"),
			Src:      m("/mnt/dev"),
			Optional: true,
			Device:   true,
		}, true, container.Ops{&container.BindMountOp{
			Source: m("/mnt/dev"),
			Target: m("/dev"),
			Flags:  container.BindWritable | container.BindDevice | container.BindOptional,
		}}, m("/dev"), ms("/mnt/dev"),
			"d+/mnt/dev:/dev"},

		{"full write dev", &hst.FSBind{
			Dst:    m("/dev"),
			Src:    m("/mnt/dev"),
			Write:  true,
			Device: true,
		}, true, container.Ops{&container.BindMountOp{
			Source: m("/mnt/dev"),
			Target: m("/dev"),
			Flags:  container.BindWritable | container.BindDevice,
		}}, m("/dev"), ms("/mnt/dev"),
			"d*/mnt/dev:/dev"},

		{"full write", &hst.FSBind{
			Dst:   m("/tmp"),
			Src:   m("/mnt/tmp"),
			Write: true,
		}, true, container.Ops{&container.BindMountOp{
			Source: m("/mnt/tmp"),
			Target: m("/tmp"),
			Flags:  container.BindWritable,
		}}, m("/tmp"), ms("/mnt/tmp"),
			"w*/mnt/tmp:/tmp"},

		{"full no flags", &hst.FSBind{
			Dst: m("/etc"),
			Src: m("/mnt/etc"),
		}, true, container.Ops{&container.BindMountOp{
			Source: m("/mnt/etc"),
			Target: m("/etc"),
		}}, m("/etc"), ms("/mnt/etc"),
			"*/mnt/etc:/etc"},

		{"nil dst", &hst.FSBind{
			Src: m("/"),
		}, true, container.Ops{&container.BindMountOp{
			Source: m("/"),
			Target: m("/"),
		}}, m("/"), ms("/"),
			"*/"},
	})
}