From 1f0226f7e01822a2a5b37d8626b59b7b6f4d0144 Mon Sep 17 00:00:00 2001 From: Ophestra Date: Tue, 7 Oct 2025 23:56:19 +0900 Subject: container/check: relocate overlay escape This is used in hst to format strings. Signed-off-by: Ophestra --- container/check/overlay_test.go | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 container/check/overlay_test.go (limited to 'container/check/overlay_test.go') diff --git a/container/check/overlay_test.go b/container/check/overlay_test.go new file mode 100644 index 00000000..bd90236d --- /dev/null +++ b/container/check/overlay_test.go @@ -0,0 +1,27 @@ +package check_test + +import ( + "testing" + + "hakurei.app/container/check" +) + +func TestEscapeOverlayDataSegment(t *testing.T) { + testCases := []struct { + name string + s string + want string + }{ + {"zero", "", ""}, + {"multi", `\\\:,:,\\\`, `\\\\\\\:\,\:\,\\\\\\`}, + {"bwrap", `/path :,\`, `/path \:\,\\`}, + } + + for _, tc := range testCases { + t.Run(tc.name, func(t *testing.T) { + if got := check.EscapeOverlayDataSegment(tc.s); got != tc.want { + t.Errorf("escapeOverlayDataSegment: %s, want %s", got, tc.want) + } + }) + } +} -- cgit v1.3.1