aboutsummaryrefslogtreecommitdiffhomepage
path: root/container/path_test.go
blob: 9af2d2f9d7985717204df0a6a2d3e42cf6f0e1db (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
package container

import "testing"

func TestToSysroot(t *testing.T) {
	testCases := []struct {
		name string
		want string
	}{
		{"", "/sysroot"},
		{"/", "/sysroot"},
		{"//etc///", "/sysroot/etc"},
	}
	for _, tc := range testCases {
		t.Run(tc.name, func(t *testing.T) {
			if got := toSysroot(tc.name); got != tc.want {
				t.Errorf("toSysroot: %q, want %q", got, tc.want)
			}
		})
	}
}

func TestToHost(t *testing.T) {
	testCases := []struct {
		name string
		want string
	}{
		{"", "/host"},
		{"/", "/host"},
		{"//etc///", "/host/etc"},
	}
	for _, tc := range testCases {
		t.Run(tc.name, func(t *testing.T) {
			if got := toHost(tc.name); got != tc.want {
				t.Errorf("toHost: %q, want %q", got, tc.want)
			}
		})
	}
}

// InternalToHostOvlEscape exports toHost passed to escapeOverlayDataSegment.
func InternalToHostOvlEscape(s string) string { return escapeOverlayDataSegment(toHost(s)) }