aboutsummaryrefslogtreecommitdiffhomepage
path: root/hst/fslink_test.go
blob: c8583544138e61e534d94bd5f605243a9e492d67 (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
package hst_test

import (
	"testing"

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

func TestFSLink(t *testing.T) {
	checkFs(t, []fsTestCase{
		{"nil", (*hst.FSLink)(nil), false, nil, nil, nil, "<invalid>"},
		{"zero", new(hst.FSLink), false, nil, nil, nil, "<invalid>"},

		{"deref rel", &hst.FSLink{Target: m("/"), Linkname: ":3", Dereference: true}, false, nil, nil, nil, "<invalid>"},
		{"deref", &hst.FSLink{
			Target:      m("/run/current-system"),
			Linkname:    "/run/current-system",
			Dereference: true,
		}, true, container.Ops{
			&container.SymlinkOp{
				Target:      m("/run/current-system"),
				LinkName:    "/run/current-system",
				Dereference: true,
			},
		}, m("/run/current-system"), nil,
			"&/run/current-system:*/run/current-system"},

		{"direct", &hst.FSLink{
			Target:   m("/etc/mtab"),
			Linkname: "/proc/mounts",
		}, true, container.Ops{
			&container.SymlinkOp{
				Target:   m("/etc/mtab"),
				LinkName: "/proc/mounts",
			},
		}, m("/etc/mtab"), nil, "&/etc/mtab:/proc/mounts"},

		{"direct rel", &hst.FSLink{
			Target:   m("/etc/mtab"),
			Linkname: "../proc/mounts",
		}, true, container.Ops{
			&container.SymlinkOp{
				Target:   m("/etc/mtab"),
				LinkName: "../proc/mounts",
			},
		}, m("/etc/mtab"), nil, "&/etc/mtab:../proc/mounts"},
	})
}