diff options
Diffstat (limited to 'container/path_test.go')
| -rw-r--r-- | container/path_test.go | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/container/path_test.go b/container/path_test.go new file mode 100644 index 00000000..9af2d2f9 --- /dev/null +++ b/container/path_test.go @@ -0,0 +1,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)) } |
